📅  最后修改于: 2022-03-11 15:01:30.157000             🧑  作者: Mango
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 };