You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cannot get the Date or DateTime scalars to work. I can see why it is not working because the REGEX is rejecting the string being producted by JSON.stringify. I'm am creating an input object with a Date field that is initialised with new Date(). In the fetch the JSON.stringify converts the date object into "2023-08-31T16:57:53.991Z".
If I pass a Date with the format: "2023-08-31T16:57:53.991Z" to either the Date or DateTime scalars, the REGEX expressions in validator.js fails.
I cannot get the Date or DateTime scalars to work. I can see why it is not working because the REGEX is rejecting the string being producted by JSON.stringify. I'm am creating an input object with a Date field that is initialised with new Date(). In the fetch the JSON.stringify converts the date object into "2023-08-31T16:57:53.991Z".
If I pass a Date with the format: "2023-08-31T16:57:53.991Z" to either the Date or DateTime scalars, the REGEX expressions in validator.js fails.
In validateDate the REGEX is
const RFC_3339_REGEX = /^(\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]))$/;
in ValidateDateTime the REGEX is:
const RFC_3339_REGEX = /^(\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60))(.\d{1,})?(([Z])|(+|-:[0-5][0-9]))$/;
This REGEX works fine:
const RFC_3339_REGEX = /^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:.\d+)?))(Z|[+-]\d{2}:\d{2})?)$/;
(see https://regex101.com/r/qH0sU7/1).
Is this a fault with the vaildation REGEX or with the way I am using the scalars?
The text was updated successfully, but these errors were encountered: