Ensure parser uses errorMessage for minContains/maxContains#229
Merged
aeschli merged 1 commit intomicrosoft:mainfrom Apr 22, 2024
Conversation
Prior to this change, the language server ignored any defined `errorMessage` when a subschema fails validation for a `contains` keyword and `minContains` is defined. The `errorMessage` was only used when `minContains` was not defined and no item in the array matched the subschema. Even if `minContains` isn't defined, the parser ignores `errorMessage` when the array contains more matching items than `maxContains` allows. This change updates the parser to use the `errorMessage`, if defined, for any failure of the `contains` keyword, regardless of the values of `minContains` and `maxContains`. This is useful for cases where a developer wants to define an error message indicating both what the schema expects to contain and how many times. The default error message is not very helpful in these cases, because most users won't know how to look up "the contains contraint" for whatever file they're working with.
aeschli
approved these changes
Apr 22, 2024
Tyriar
approved these changes
Apr 22, 2024
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.
Prior to this change, the language server ignored any defined
errorMessagewhen a subschema fails validation for acontainskeyword andminContainsis defined. TheerrorMessagewas only used whenminContainswas not defined and no item in the array matched the subschema. Even ifminContainsisn't defined, the parser ignoreserrorMessagewhen the array contains more matching items thanmaxContainsallows.This change updates the parser to use the
errorMessage, if defined, for any failure of thecontainskeyword, regardless of the values ofminContainsandmaxContains.This is useful for cases where a developer wants to define an error message indicating both what the schema expects to contain and how many times. The default error message is not very helpful in these cases, because most users won't know how to look up "the contains contraint" for whatever file they're working with.