I'm using Joi package to validate a timestamp field but How can I set a max() value on it, I want the input timestamp to be less than current time stamp
var schema = Joi.object().keys({
t: Joi.date().timestamp('unix').max(moment().unix()),
})
but I get the error that:
child "t" fails because ["t" must be less than or equal to "Sun Jan 18 1970 07:35:17 GMT+0330 (IRST)"]
I'm sure that the moment().unix()
returns the current timestamp, but here it is casted to string.
It seems that
max()
andmin()
functions can do the trick but they only work if the threshold is specified in milliseconds.