-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
deepProperties support for relative and absolute pointers #29
Comments
I don't understand why you need to validate one deep property from another. It's possible to allow root-based absolute and relative JSON pointers, but that would mean full rewrite of this keywords and changes in deepRequired - should be a major version change. |
I thought about this some more, and I think you're right - I may not need it. I'm doing government forms and have ridiculously complex rules, and am looking to write a generic form and rule generator. Suppose I have data that looks like this:
The rule might be "if incident.parked is true, then at least one vehicle's driver must have firstname='none' and also have at least one element in its damage section" For the last part(about the driver firstname and the damage section - I was thinking of using deep properties like so:
|
The last snippet is equivalent to: {
properties: {
vehicles: {
deepProperties: {
"/driver/firstname" : {const: 'unknown'},
"1/damage" : // I assume it should not be relative in this case as well
}
}
}
} |
Hello,
From the readme for deepProperties:
This keyword allows to validate deep properties (identified by JSON pointers).
I have a need to validate 'cousin' properties inside an array. I've tried this:
And got: keyword schema is invalid: data should match format "json-pointer", data property name '2/child2/grandchild2' is invalid.
Tracing a bit - it looks like the validation code from ajv/lib doesn't support relative pointers.
I can build another custom keyword to wrap deepProperties I think, but wanted to report this either for fixing or for clarifying.
Thanks!
Koby
The text was updated successfully, but these errors were encountered: