-
Notifications
You must be signed in to change notification settings - Fork 935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Date range validation #255
Comments
hmm this should work, can you provide an example without moment so i can play around with it? |
Unlike the documentation, I got this working by using
|
Hi, im really new to the lib, but i have the same exact issue using 'when' with dates. attaching min/max to schema using 'when' leads to this problem. |
Really, thank you so much @andrewzamojc-pd I lost like two days trying different things but with your answer it DOES work! |
@andrewzamojc-pd actually if you want to use schema you should remove .date() because it is already defined at the begining of you expression so your code should look like this: |
I've not had any luck with date range validation either. Very well may be going about it in the wrong way. My schema is a bit different in that I have my date as an object with
|
@ahummel25 From what I gather, you have day(I am assuming you mean date eg. 01-01-1970) and time(eg 10:00:00) separately, but you have mentioned day and time both to use date validator which might break, since JS date.parse() doesn't have ability to parse time alone. I am hoping you could adapt your code in same way I have written the solution for in #642 making use of a time library like moment which would support time format without any date associated with it. Please refer this Stackoverflow QnA to get more idea on what I mean. |
I am using like this and its working
|
@harshiths97 I assume this will work fine since both Not sure if there is way to do validation in an object like below, especially if you have a web form that allows user to pick date and time for events.
This something similar to what @ahummel25 mentioned at #255 (comment). |
I am new to Yup. My validation needs to have 1 day less than ref('startDate'). I couldn't figure out a way to do it.
|
I'm really excited about this library, however I found an issue that I'm not sure how to deal with. I'd like to be able to validate a date range, but it doesn't seem to work. I've written two tests to show what does and does not work for me.
The first test works, but I get an error message
RangeError: Maximum call stack size exceeded
on the second test. Is there something I can do differently to validate a date range?The text was updated successfully, but these errors were encountered: