import { object, string, number } from 'yup'; const employeeCreateValidator = (req, res, next) => { const employeeSchema = object({ name: string().required(), city: string(), salary: number() }) employeeSchema.validate(req.body) .then(() => next()) .catch(err => { res.status(400) res.json({ success: false, message: err.message }) }) } export { employeeCreateValidator }