Joi: How we can compare end date is greater than or equal to start date

Created on 21 May 2020  路  1Comment  路  Source: sideway/joi

Hi,

below one is my schema:-

schema: Joi.object().keys({
    start_time: Joi.date().timestamp().required(),
    end_time: Joi.date().timestamp().greater(Joi.ref('start_time')).required(),
  }),

currently above schema validate only end date is greater than start date but I also want to add one more condition like end date is equal to start date and it should pass.

is there any solution for that?

support

Most helpful comment

Use .min() instead of .greater().

>All comments

Use .min() instead of .greater().

Was this page helpful?
0 / 5 - 0 ratings