Describe the bug
Documentation states: "By default ISO date strings will parse correctly." but casting ISO strings representing dates before epoch (e.g. "1969-06-20T20:17:00.000Z") will produce an error:
Uncaught TypeError: The value of field could not be cast to a value that satisfies the schema type: "date".
attempted value: 1969-06-20T20:17:00.000Z
result of cast: Invalid Date
To Reproduce
https://codesandbox.io/s/trusting-cloud-7bbv7
Expected behavior
Valid ISO 8601 dates should be parsed properly regardless of whether they represent pre-epoch dates.
Platform (please complete the following information):
Additional context
This bug has been introduced in yup 0.28.0. It was not present in 0.27.0.
PR https://github.com/jquense/yup/pull/655 seems to be broken. I think instead of
-return value ? ...
+return value > -1 ? ...
it should be
-return value ? ...
+return !isNaN(value) ? ...
ISO date validation seems definitely broken in 0.28. I'm back to 0.27 and its working fine now.
PR #655 seems to be broken. I think instead of
-return value ? ... +return value > -1 ? ...it should be
-return value ? ... +return !isNaN(value) ? ...
I completely agree with this.
I'm having errors while validating dates before 01/01/1970, as all those dates have a negative value on the UNIX system.
Most helpful comment
PR https://github.com/jquense/yup/pull/655 seems to be broken. I think instead of
it should be