Celebrar el nodo JS
router.post('/',userMiddleWare, (req, res) => {});
const { celebrate, Joi, errors, Segments } = require("celebrate");
const userMiddleware = celebrate({
body: Joi.object().keys({
firstName: Joi.string().trim().min(2).max(30).required(),
lastName: Joi.string().trim().min(2).max(30).required(),
email: Joi.string()
.trim()
.min(2)
.max(30)
.required()
.pattern(new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/)),
password: Joi.string()
.trim()
.min(2)
.max(30)
.required()
.pattern(
new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9_])")
),
role_id: Joi.string().trim().required(),
position_id: Joi.string().trim().required(),
}),
});
module.exports = { userMiddleware };
Fierce Ferret