Is there a way to pre-process data using the Joi validation package?

Viewed 28

Is there a way that you can provide some sort of function to a Joi validation schema that will pre-process the value before it gets validated by Joi rules? For example, if a user inputs a date in some arbitrary format, can I call some processing function that formats the input prior to undergoing Joi validation?

const schema = Joi.object({
  "date": Joi.someFunc((originalValue) => {
    return convertToSomeFormat(originalValue);
  }).date(),
});

0 Answers
Related