UNPKG

jambda

Version:

Easy serverless rest api deploy! Jambda makes it easy to deploy database connected rest api's by providing the least amount of configuration.

27 lines (23 loc) 528 B
import { badData } from 'boom' /** * Helper function to set the error response for invalid models * * @param {Schema} model The model * @param {Function} reject The reject callback * @param {Function} callback The success callback * @returns {void} */ const validate = (model, reject, callback) => { model.isValid(isValid => { if (!isValid) { return reject( badData( 'Invalid data provided, please verify and try again!', model.errors ) ) } callback(model) }) } export default validate