Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message is redundant with literals #311

Open
Wykaz opened this issue May 13, 2024 · 0 comments
Open

Message is redundant with literals #311

Wykaz opened this issue May 13, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Wykaz
Copy link

Wykaz commented May 13, 2024

Is there a way to make literal z.union responses less redundant ?

For example:

z.object({
    DEBUG: z.union([
        z.literal("0"), z.literal("false"),
        z.literal("1"), z.literal("true")
    ]),
});

if I don't pass the "DEBUG" field or if I put a invalid value, it returns:

Validation error: Invalid literal value, expected "0" at "DEBUG", or Invalid literal value, expected "false" at "DEBUG", or Invalid literal value, expected "1" at "DEBUG", or Invalid literal value, expected "true" at "DEBUG"

I would have seen something that looked like this:

Validation error: Invalid literal value, expected "0", "false" "1" or "true" at "DEBUG"
@jmike jmike self-assigned this May 13, 2024
@jmike jmike added the enhancement New feature or request label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants