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

[Feature] one of or or type #1182

Open
andreisaikouski opened this issue May 11, 2023 · 2 comments
Open

[Feature] one of or or type #1182

andreisaikouski opened this issue May 11, 2023 · 2 comments

Comments

@andreisaikouski
Copy link

Add a one of or or type link in Joi.or()

e.g.
I want to validate that type User has at least one of name or email

interface User {
    tel: number;
    address: string;
    name?: string;
    email?: string;
}
@jakubwolny
Copy link
Contributor

wouldn't be enough to create a union of 2 types (one with name required, and other with email required)?

@andreisaikouski
Copy link
Author

@jakubwolny in my project we have larger interfaces which would require significant code duplication.
Currently I accomplished this with a refine that then checks for one or the other, but would be easier like Joi.or()

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

2 participants