Closed
Description
Have an issue with a valid datetime value, as produced by the browser in a datetime picker field, is not accepted by the datetime()
validation. After some digging I figured that when the seconds :00
are added the validation passes.
But according to ISO 8601, just the hour is required for a valid time. Also as the timestamp is produced like this "2024-07-18T11:00"
, I feel it would be really great if this is accepted by the library as also the Date constructor doesn't have any issue with this.
For now I had to put in a quite ugly preprocess
to make the validation pass on the value provided by the browser:
z.preprocess(input => `${input}:00`,
z.string().datetime({ local: true }))
Metadata
Metadata
Assignees
Labels
No labels