-
Notifications
You must be signed in to change notification settings - Fork 356
Moving constraints min- and maxProperties to ObjectConstraint #232
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
Conversation
…ested from PR 224 and fixing issue 215.
return; | ||
} | ||
|
||
if (!is_object($schema)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can leave this in to maintain better BC
@rtucek thanks for verifying the fix. How about we revert the initial I have applied the patch of this PR to my local copy and only the later changes have any bearing on the After that, we are good to go. |
@bighappyface unfortunately it's far more complicated: So far it's only triggered if However, based its current implementation, in order to run the objectConstraint against the current
or (B) always trying to run the objectConstraint against I think the underlying problem is that objectConstraint was only (and really only) build for the purpose of checking "properties", "patternProperties" and "additionalProperties" keywords if at least one of them is present. So if the objectConstraint ever gets extended by additional checks (like min-/maxProperties), you'd have to add additional logic... |
I am still unclear why the exception has to be removed and I think it is important to reiterate the importance of backward compatibility considering consumer code out there may be looking to catch exceptions to indicate a bad schema. |
Yeah, I agree that this may break BC for people who're probably expecting bad schema. I still would suggest #233 which has way less influence on BC. On the flip side the check still belongs to UndefinedConstraint. If you'd like to enforce having the min-/maxProperties check in the objectConstraint - refactoring that class is unfortunately required. From my point of view, there is no other way around. |
IMO the check for anything other than #233 is definitely minimal but I am not completely convinced that there isn't some unintended consequence, but that is likely true for this PR as well. Overall I think getting the +1 |
Moving constraints min- and maxProperties to ObjectConstraint
As requested in #224, I've moved the min-/maxProperties constraint from UndefinedConstraint to ObjectConstraint.