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

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