How can I validate optional dates? #1169
Answered
by
muningis
jack-allocate
asked this question in
Q&A
-
|
I have a date input thats optional. But, if they do input something, I want to validate that its an ISO date. date: v.pipe(
v.optional(v.string()),
v.transform((value) => value ?? new Date().toISOString()),
v.isoDate(),
),I managed to get it working with the above, but I'm wondering if theres something easier. |
Beta Was this translation helpful? Give feedback.
Answered by
muningis
Apr 25, 2025
Replies: 1 comment 1 reply
-
|
Switching |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jack-allocate
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Switching
pipeandoptionalaround seems to workPlayground link