date field validation bug
See original GitHub issueDescribe the bug
When yup.date()
field gets empty string for validation, it throws error even if field is nullable or not required.
ValidationError: required must be a
date
type, got: “Invalid Date” instead
To Reproduce https://runkit.com/michal-de/yup-date-bug
Expected behavior
Empty string case should be considered as null
or undefined
.
Platform (please complete the following information):
- Browser: chrome
- Version: 79.0.3945.130 (Official Build) (64-bit)]
Additional context
Empty string is default html input value for type date
or datetime-local
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Date field keeps giving validation error even though submitted ...
I'm having a strange problem with a date field on a webform. I have it set, in the Element Settings, to a minimum...
Read more >Date Valid Bug? | OutSystems
You will have to validate for example if the field is a Date and if the variable is not empty. And so you...
Read more >"Date" Field Validation Error - Laracasts
i have two question. I put data in both field "Department Name" and "Starting Date" but validation message occur that "The depjdate field...
Read more >Why am I getting a Date/Time Validation error when entering ...
Why am I getting a Date/Time Validation error when entering data in Quality Window? · A bad Date/Time was entered manually · The...
Read more >date field failed validation error - General Product Use
Even when using the date field drop-down calendar to fill in the date I am getting the error message "date field failed validation....
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
Fixed with
nullable
andtransform
, to avoid polluting the input/html code:yearEndDate: date().nullable().typeError('Invalid Date')
works like dream.