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

Using allow after valid is not working #494

Open
Pnlvfx opened this issue Dec 4, 2024 · 1 comment
Open

Using allow after valid is not working #494

Pnlvfx opened this issue Dec 4, 2024 · 1 comment

Comments

@Pnlvfx
Copy link

Pnlvfx commented Dec 4, 2024

Describe the bug
If you add the allow operator after using the valid it will only pick the valid.

example:

export const ciaoSchema = Joi.string().valid('Ciao').allow(null).meta({className: 'Data'})

will output:

type Data = 'Ciao'

instead of:

type Data = 'Ciao' | null

@Pnlvfx
Copy link
Author

Pnlvfx commented Dec 4, 2024

Describe the bug If you add the allow operator after using the valid it will only pick the valid.

example:

export const ciaoSchema = Joi.string().valid('Ciao').allow(null).meta({className: 'Data'})

will output:

type Data = 'Ciao'

instead of:

type Data = 'Ciao' | null

I know That I can add the null on the valid, but when you have a reusable type it's not always possible to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant