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
Allow null to pass on any type #130
Comments
Doesn't passing the type as an array work?
|
Yes it does! Thank you very much. Might want to throw that in the docs? |
Yeah that could be nice, although I don't think that we mention anything about how JSON schema actually works att all. The array thing is just part of regular JSON schema, and isn't special to this implementation... |
Right I agree, but it isn't clear that you allow more than one type to be checked by providing an array? |
In some cases it might be useful to allow null to pass given any check for type.
For example given the following JSON:
We may construct our rules like this:
Now say we want to allow
b
to be a boolean when it is defined but also allow it be null.We can update our rules to look like this:
But if we cant d to be a nested object like originally shown or null using the same trick for
b
(see rule below) that will error because if isd
is in fact null it will try to read a property that doesn't existI'm not even sure if the
||
is valid but it does work in the case when the type isn't object but it would be nice to have something like allowNull key.So the rules could like something like this:
The text was updated successfully, but these errors were encountered: