Does nodejs celebrate middleware support conditional validation of a segment depending on what values are in another segment?

19 views Asked by At

For example I want to validate Segments.BODY depending on a value defined in SEGMENTS query, but I can't seem to find a solution with celebrate. I don't understand why tough, would this mean bad practice?

  [Segments.BODY]: (value, helpers) => {

   // do some conditional validation based on the query params
   return Joi.object()
    .keys({
      name: Joi.string().alphanum().min(2).max(30).required(),
      email: Joi.string().required().email(),
    })
    .validate(value, joiConfig);
   },
0

There are 0 answers