fix(schema): allow empty array for required field with minItems#258
Open
spiderocious wants to merge 1 commit into
Open
fix(schema): allow empty array for required field with minItems#258spiderocious wants to merge 1 commit into
spiderocious wants to merge 1 commit into
Conversation
…ields with minItems
Author
|
@sandrina-p @danielcardoso5 please review |
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.
Fixes a bug where a
requiredarray property fails validation when given anempty array, even though the schema explicitly allows it via
minItems: 0.A required
group-arraywithmin: 0could never be submitted empty.Changes Made
src/validation/schema.tsrequiredcheck, an empty array is no longer automatically treatedas a missing value when the field schema declares
minItems. In that casethe array counts as present, and its length is validated by
minItems(which runs separately) rather than by
required.minItems: an empty array is still treated as missing, preserving existingbehaviour.
test/validation/required_field.test.tsminItems: 0accepts an empty array.minItems: 1reports aminItemserror (not a
requirederror) for an empty array, confirming length isstill enforced by the right mechanism.
minItemsstill treats an emptyarray as missing.
Related Issues/PRs
Fixes #247
Checklist