I've got a function which enforces validation restrictions via obj.pattern
.
The key which I would like to validate is a formatted date which is provided to the function in the following format DD/MM/YYYY
.
I am using Joi.date
to validate against this value which is fine when the day is less than the 12th of month. If it is more, it returns an error. The assumption is that the default JOI format is MM/DD/YYYY
which would obviously result in an error since there are 12 months in the calendar year.
This is reflected in the console log - If i change the day value in numberField
to anything greater than 12 then I can see the error. If it stays below then there is no error thrown.
I would like to figure out how I can format this response so that JOI can validate the correct schema. I've simplified and reduced the issue to a prototype which I am sharing here: https://codesandbox.io/embed/naughty-booth-862wb
Can anyone help?