You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The "now" keyword passed to date.min and date.max creates a new Date when the schema is compiled.
It would make more sense if the date was created when validating the schema.
In this example the validation fails because test_date is created one second after the schema.
varJoi=require('joi');varschema=Joi.date().max('now');vartest_date;setTimeout(function(){test_date=newDate();},1000);setTimeout(function(){varresult=Joi.validate(test_date,schema);// result.error -> "validate: value must be less than or equal to ..."console.log('Validation error:',result.error);},2000);
A solution could be to keep "now" in the _tests part of the schema and convert to date when validating:
Observed in 4.8.0
The "now" keyword passed to date.min and date.max creates a new Date when the schema is compiled.
It would make more sense if the date was created when validating the schema.
In this example the validation fails because
test_date
is created one second after the schema.A solution could be to keep "now" in the _tests part of the schema and convert to date when validating:
The text was updated successfully, but these errors were encountered: