-
Notifications
You must be signed in to change notification settings - Fork 14
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 minProperties and maxProperties on objects #53
Support minProperties and maxProperties on objects #53
Conversation
HHVM_VERSION=4.102.2 | ||
HHVM_NEXT_VERSION=4.102.2 |
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 noticed @sarahhenkens also updated HHVM_VERSION
in her PR #52, should we also update HHVM_NEXT_VERSION
? i wasn't 100% sure if they should always match
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.
hmm I think we should probably update this to 4.121
?
$max_properties = $this->typed_schema['maxProperties'] ?? null; | ||
$min_properties = $this->typed_schema['minProperties'] ?? null; |
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.
someone asked about whether we should validate if these integers are non-negative. i noticed we don't validate that for StringMinLengthConstraint
or ArrayMinItemsConstraint
- is there a reason/context for that?
if we were to add that check for objects, i'm trying to figure out where the best place for it would be so that it'd error out for the developer trying to generate a schema with negative min/max numbers. doesn't seem like the getCheckMethod
is the right place.
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.
It wasn't intentional that we left those off, just didn't get around to it. I'd add it anywhere in this codegen path, maybe above where you set the class properties?
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.
okay, sounds good - i added checks for those above in the build
method & tested that it throws an error when trying to generate a file that has invalid min/max values.
$max_properties = $this->typed_schema['maxProperties'] ?? null; | ||
$min_properties = $this->typed_schema['minProperties'] ?? null; |
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.
It wasn't intentional that we left those off, just didn't get around to it. I'd add it anywhere in this codegen path, maybe above where you set the class properties?
Description
Adds support for
minProperties
andmaxProperties
for objects. Partly completes: #5Leveraged a lot of the existing patterns we have for
minItems
andmaxItems
in arrays. So we created two new classes in this PR:ObjectMaxPropertiesConstraint
andObjectMinPropertiesConstraint
that are used in theObjectBuilder
class.Testing
Updated unit tests and also manually tested