UNPKG

express-api-cli

Version:

Cli tool for generating an express project. Instead of wasting extra time creating your project structure, start building right away

17 lines (15 loc) 402 B
import Joi from '@hapi/joi'; export const newUserValidator = (req, res, next) => { const schema = Joi.object({ firstName: Joi.string().min(3).required(), lastName: Joi.string().min(3).required(), email: Joi.string().min(3).required() }); const { error, value } = schema.validate(req.body); if (error) { next(error); } else { req.validatedBody = value; next(); } };