feat: validate enum values for properties and collections#204
Open
crisnahine wants to merge 3 commits intoseuros:masterfrom
Open
feat: validate enum values for properties and collections#204crisnahine wants to merge 3 commits intoseuros:masterfrom
crisnahine wants to merge 3 commits intoseuros:masterfrom
Conversation
the original had collection_definition.merge!(opts) which put enum at the array level. in JSON Schema, enum on an array means the entire value must match — not that each item must be in the list. moved enum to items where it belongs. also: nil guard in ArrayEnumValidator, stale comment cleanup.
ArrayEnumValidator was placed after `return unless required`, so non-required collections with enum never got validated. Moved it before the guard. Also removed dead `allow_nil: !required` (always false after the required guard).
0291153 to
f6fee3b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rebased and fixed version of #184 by @dark-panda.
adds enum validation for
propertyandcollectionDSL on tools. properties use ActiveModelinclusionvalidation, collections use a customArrayEnumValidatorthat checks each item.fix from the original:
collection_definition.merge!(opts)was puttingenumat the array level in the JSON Schema output. in JSON Schema, enum on an array means the entire value must be one of the listed values — not that each item should be. moved it toitemswhere it belongs:also added nil guard in
ArrayEnumValidatorand cleaned up a stale comment.