Validate two input dates and max/min ranges
See original GitHub issueI have two date fields, one for startDate
and the other for endDate
.
How to validate the startDate
not going over the endDate
(max value)? And the opposite as well, the endDate
not going farther than the startDate
(min value).
I tried doing the following but resulted in a cyclic dependency
startDate: yup
.date()
.when(
'endDate',
(endDate, schema) => (endDate && schema.max(endDate)),
),
endDate: yup
.date()
.when(
'startDate',
(startDate, schema) => (startDate && schema.min(startDate)),
),
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:8
Top Results From Across the Web
Advice on how to compare a date input value against min ...
I see you are already using moment . You can parse the date strings using moment and get a native date object from...
Read more >Min / Max Date Validation and Compare Validation for Two ...
In some cases you want to have the end users select dates within given ranges and to ensure one date is before the...
Read more >Dynamically set the max min date at input field with React
In this article, I will show you a very simple example to demonstrate the situation that if you writing a admin to limit...
Read more >Lookup min max values within a date range
This article explains how to find the smallest and largest value using two conditions. In this case they are date conditions but they...
Read more >creating a date range with two input type date widgets
<form action="#" class="ws-validate">. 2. <div class="form-row">. 3. <!-- max of the first date equals value of the second --> <!-- mmin of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What about
I am also facing a similar issue, why someone has not posted an answered to this problem?