Skip to content

or condition? #362

Answered by fabian-hiller
mwskwong asked this question in Q&A
Jan 10, 2024 · 2 comments · 9 replies
Discussion options

You must be logged in to vote

Note: With v0.26.0 the behavior has changed to improve the DX. The schema must now be written as follows:

import * as v from 'valibot';

const EmailSchema = v.optional(
  v.union([v.string([v.email('Not a valid email')]), v.literal('')])
);

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
9 replies
@mwskwong
Comment options

@mwskwong
Comment options

@fabian-hiller
Comment options

@fabian-hiller
Comment options

@mwskwong
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by fabian-hiller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants