📜  庆祝节点 js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:30.157000             🧑  作者: Mango

代码示例1
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 };