Skip to content

Conversation

@michaeltlombardi
Copy link
Contributor

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.

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.
@vscodenpa vscodenpa added this to the April 2024 milestone Apr 22, 2024
@aeschli aeschli merged commit 31dc8ea into microsoft:main Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants