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

Differentiate .allow from .valid #43

Merged
merged 9 commits into from
Mar 3, 2019

Conversation

Mr4k
Copy link
Contributor

@Mr4k Mr4k commented Feb 27, 2019

Somewhat related to this issue:
#11
From what I can tell, currently .allow() and .valid() both just whitelist the given values and blacklist everything else. I think this change should make it so that .allow whitelists the given values while still allowing all values of the original type. I have found this useful for cases where schema users do things such as:

Joi.string().allow(null)

Edit: Also made a last minute change from oneOf to anyOf because I think that oneOf could be problematic in cases where you are allowing an instance of type (which shouldn't be done but still could be) such as

Joi.string().allow('hello');

@lightsofapollo
Copy link
Owner

@Mr4k I think this LGTM ... I will release it under a new feature version shortly.

@lightsofapollo lightsofapollo merged commit d87a11e into lightsofapollo:master Mar 3, 2019
@lightsofapollo
Copy link
Owner

In v4.0.0

@Mr4k
Copy link
Contributor Author

Mr4k commented Mar 3, 2019

thanks!
out of curiosity do you know which oneOf was previously -----oneOf?

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

Successfully merging this pull request may close these issues.

2 participants