Skip to content

Conversation

p-spacek
Copy link
Contributor

@p-spacek p-spacek commented Oct 10, 2025

What does this PR do?

adds an errorMessage from the schema when the property is missing
allows customization of the errorMessage in more complicated scenarios, like

anyOf: [
          {
            required: ['title'],
            errorMessage: 'At least one of `title` or `icon` must be defined.',
          },
          {
            required: ['icon'],
          },
        ],

What issues does this PR fix or reference?

Is it tested? How?

test

@coveralls
Copy link

coveralls commented Oct 10, 2025

Coverage Status

coverage: 83.961% (+0.005%) from 83.956%
when pulling 4977373 on jigx-com:feat/add-errorMessage-from-schema-when-the-property-is-missing
into 410cff9 on redhat-developer:main.

@datho7561
Copy link
Contributor

datho7561 commented Oct 10, 2025

Does any other YAML/JSON validation service support this? It seems like an odd thing for us to introduce in the yaml-language-server unless it's in the JSON Schema specification or there's an established convention for doing this.

Yes, VS Code's JSON language server supports it.

I can see that vscode-json-languageservice has it listed here: https://github.com/microsoft/vscode-json-languageservice/blob/e0f39f09a3e693f3a0895a051efd4895cbc6a746/src/jsonSchema.ts#L78, but I can't seem to get it to actually show the message I set when working with JSON in VS Code.

Nevermind, got it working in VS Code. The specific scenario I tried initially didn't work properly, though.

Also, it seems we already support errorMessage for many scenarios, my bad.

@p-spacek p-spacek requested a review from datho7561 October 13, 2025 07:01
@datho7561 datho7561 added this to the 1.20.0 milestone Oct 14, 2025
Copy link
Contributor

@datho7561 datho7561 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks, Petr!

@datho7561 datho7561 merged commit afb9b96 into redhat-developer:main Oct 14, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants