Skip to content
Advertisement

start and end date should be different for one year

Hi there I’m using Yup as a validator for one of my schemas

This is my code here for validating schema

JavaScript

This works but I can add the same date for the start date and end date.

I want that end date to be different and higher than start date

Thanks a lot

Advertisement

Answer

You can try Yup.when to handle this,

It provides you a trigger on which field change the schema should be recomplied and schema object for handling validations

JavaScript

Please find sample codesandbox here

Advertisement