-
-
Notifications
You must be signed in to change notification settings - Fork 877
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
Support multiple property names in discriminator
keyword
#1663
Comments
You can achieve it by nesting discriminators, or you can define a custom macro keyword to do it for you. discriminator is half-standard so changing it is probably wrong. |
I tried nesting discriminator in the following schema:
but I am getting the error |
Yes, it only supports strings |
Would you be open for a PR to support other values like numbers and boolean? |
Yes - that should be doable I think - thank you! |
So effectively any scalar value can be matched with discriminator and you can use the same approach as in select keyword to make them object keys, so true as string is not the same as true as Boolean. Also worth supporting null in this case. |
(Select is defined in ajv-keywords for the reference) |
I have seen |
I only meant to use it to support discriminator improvement - not suggesting to use it instead. Let me know if you have any questions. |
I am working on extending discriminator with other values then string. Can I use Map object or would it create compatibility issue with older browsers? |
Here you go @epoberezkin #1729. Let me know what do you think? |
What version of Ajv you are you using?
8.6
What problem do you want to solve?
My schema depends on value of two fields, so I wanted to implement something like this:
What do you think is the correct solution to problem?
Add ability to define multiple properties in
discriminator
Will you be able to implement it?
I am not sure...
The text was updated successfully, but these errors were encountered: