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

Conditional $merge and $patch keywords? #46

Open
manuschillerdev opened this issue Oct 31, 2021 · 2 comments
Open

Conditional $merge and $patch keywords? #46

manuschillerdev opened this issue Oct 31, 2021 · 2 comments

Comments

@manuschillerdev
Copy link

I am trying to merge/patch schemas based on conditions with if/then/else. Is this generally possible?

Here is a minimal reproduction CSB of what I am trying to achieve:
https://codesandbox.io/s/serene-cdn-0ugtt?file=/src/index.js

@epoberezkin epoberezkin transferred this issue from ajv-validator/ajv Nov 3, 2021
@epoberezkin
Copy link
Member

epoberezkin commented Nov 3, 2021

Looking at the example, the full path that you are trying to use in patch should be /if/properties/q, not /properties/q - did you try that?

Also, it may be just a contrived example, but why do you need to repeat the keywords from if in then? If it is validating agains then, the condition in if is definitely satisfied.

Also, you might need else: false in case you want validation to fail unless condition in if is valid...

@epoberezkin
Copy link
Member

No, was a bit confused... I am not quite sure what you are trying to achieve - other than some strict mode requirements (you can either add missing type keywords or use the option strict: false) it seems to be working?

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

No branches or pull requests

2 participants