-
-
Notifications
You must be signed in to change notification settings - Fork 309
"additionalPatternProperties": validate properties by pattern, excluding ones listed in "properties" #76
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
Comments
There is intentionally no order to properties vs patternProperties. It is effectively an Something like |
I don't understand, the link you provided actually specifies the order. Property->PatternProperty->AdditionalProperties. Am I reading it wrong?
|
"s" is the set of schemas against which to validate the child schema. Step 1: If there's a match in Implicit step 4: Validate the child instance against all schemas in "s" (effectively, an |
@dmikov A property can be evaluated by both "properties" and "patternProperties", and there's no order to keywords, so the validation result isn't effected by which one the validator considers first. Does that make sense? |
@awwright Hence my enhancement proposal. Why would you want to evaluate by both? Once you defined static property. Choosing specific over generic is a much more natural way. Kinda how lexers and tokenisers work. |
Ok, so you'd like to see any matching properties in "patternProperties" I'm not aware of anyone depending on the current behavior, though that Can you provide an example where your approach makes more sense? On Oct 10, 2016 4:14 AM, "Dmitriy Krasnikov" [email protected]
|
Gladly. I am developing workflow engine right now. As a workflow dsl language, we decided on Mistral DSL 2.0 http://docs.openstack.org/developer/mistral/dsl/dsl_v2.html Here is an excerpt from it:
As you can see the workflow name I personally can hardly find the case when combining rules from static and pattern property is beneficial. Whatever the goal is, this combination is just too unpredictable not to be dangerous, plus I imagine it can still be accomplished by combining multiple pattern properties, that would at least be somewhat expected behavior. |
I'm against this for the same reasons @handrews laid out in #77. If we did this, it would make |
@jdesrosiers I actually disagree with the idea in #77, both in relation to maximum/minimum and also as a general approach. Allowing keyword validation depend on siblings is fine, it allows to keep keywords values shallower. Being religious about keyword independence is the opposite extreme of other proposed changes where keywords become aware not only of the siblings but of everything, this extreme is equally bad. |
Having said that, making patternProperties dependent on properties is not a bad idea - in many cases it is not possible to write a regular expression that would exclude a certain string. In some cases there are workarounds but they make schema very verbose, in some cases there isn't really. |
Maybe we introduce another property called "additionalPatternProperties", keeping with the tradition of prefixing non-linear keywords with "additional". |
Maybe it's better indeed than changing semantic of patternProperties... I would at least deprecate patternProperties in this case, so they don't exist at the same time. Honestly, there are few use cases where you mix patternProperties and properties, it usually indicates questionable data design. There are even fewer cases when you want to apply the same schema to both properties and patternProperties, and even if you do, you can use allOf with $refs. So renaming patternProperties to additionalPatternProperties is probably ok - it may make transition easier. At the same time, shorter keywords are better, so I am ok with just changing the semantics too - it would affect very few people, majority of users don't mix, and it seems that every time they do mix they raise it as an issue. |
@jdesrosiers I want keyword independence actually. #77 is not related conceptually to this at all. |
Keyword independence means that |
@handrews for sure during execution they evaluated independently. However during design phase my property is not independent, it will not be validated correctly because of other - patternProperty being present somewhere in the schema. That's independence I would like to work with. For usability I would think the later is more important, since implementing validator to this is just a technicality. Sorry for confusion. |
@dmikov so essentially you want the behaviour of patternProperties keyword be dependent on the presence of properties keyword... |
@dmikov , @awwright , how do we bring this to a resolution? It seems to have quieted down. There's clear opposition to the original proposal (changing the behavior of patternProperties while keeping its name) from at least three people on this thread. There is also the "additionalPatternProperties" proposal, either alongside the current patternProperties or as a replacement. Do we want to pursue that approach further? |
Well additionalPatternProperties will solve the issue for me or at least allow to proceed. But I have to say keeping patternProperties as is - is not clean - too many side effects. The opposition here is really more about saying how people should write json (and not about jsonshema), which I think should not be discussed here at all. |
@epoberezkin I thought I didn't need to point out, that it does it anyway in one way or the other. If it combines the definition, the behavior of patternProperties is affected. That's just a nature of collision of definitions and will always be there when you evaluate tokens. |
@dmikov not sure I follow the argument. Schema validation has no side effects at all, not sure what you mean here. patternProperties is independent of properties. And you suggest to make it dependent. I don't think we should do it. |
@dmikov I think if you want to push for |
@handrews back to the process question :) On the substance, additionalPatternProperties seems weird... |
@epoberezkin I suspect @awwright would (not unreasonably) quote The Tao of IETF:
which is followed by the familiar "rough consensus and running code" quote. But I do believe that we need a better-defined notion of "rough consensus", particularly for figuring out when we can reject proposals that are not gathering support. I feel like we have a lot of those just hanging out in the queue cluttering things up. For more of this discussion, let's take it to #137. |
I don't really see a problem with having both "patternProperties" and "additionalPatternProperties". Except perhaps keyword proliferation, which is understandable. But I think if there's a good reason to have "additionalPatternProperties", that's a good reason just to add a new keyword without replacing one. Does anyone actually think this is a bad idea? I understand how it might encourage bad design practices. Usually patterns shouldn't be able to look like keywords. There's also the propertyNames keyword. @dmikov, would #172 work for you instead? That is, using a combination of |
@awwright I am against adding "additionalPatternProperties" before figuring out how to manage "additionalProperties" problems - it would only add to the confusion. At the moment "additionalProperties" is defined to validate everything that doesn't match any pattern in "patternProperties" as well, so not sure I follow why we need a separate keyword - the implication here is that we also should change the semantics of patternProperties, which is a bigger issue and many people seem to be of the opinion that it is a bad idea... |
@epoberezkin the point of @awwright I'm not sure about
I think we would be better advised to make it easier to exclude things from matching than to throw in more keywords with increasingly complex exclusion rules. You are right to bring up I feel like object property rules are getting dangerously messy and should be reconsidered holistically in a near-future draft. Consider the various other competing proposals in #106 and #117 (and probably others) as well. |
Agreed. As such, can we close this issue in favour of another solution? |
@dmikov Hasn't responded to my question if So we can close this out until someone can come up with a case where |
I encountered a very cumbersome issue, which might be related to implementation of validators, but the ones I tried all do it.
The version and image64 property fail validation since they are catched by regex on pattern and therefore must be object and not string. Yes I can write a regex excluding them, but what happen if I need to add one more static property? Edit it again. I think requiring evaluation of static properties first should be mandatory to avoid this issue.
The text was updated successfully, but these errors were encountered: