-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
javax.validation... error message from annotation to validator error message #373
Comments
Hi @VovkaSOL, Can you please point me to the part of the JSON Schema Specification where this is described? |
@CarstenWickner i can't find it in specification, but i found it in stackoverflow :-) https://stackoverflow.com/questions/40423376/json-schema-validator-custom-message victools/jsonschema-generator support this error messages format too :-) |
I see no mentioning of "message" in that JSON Schema specification. Where exactly do you see it? |
Very strange situation with custom messages for json schema validations errors, specification says " 12.3.4. Error or Annotation For errors, the specific wording for the message is not defined by this specification. Implementations will need to provide this. For annotations, each keyword that produces an annotation specifies its format. By default, it is the keyword's value. The JSON key for failed validations is "error"; for successful validations it is "annotation". but this message blocks https://stackoverflow.com/questions/40423376/json-schema-validator-custom-message work good in victools/jsonschema-generator. |
With this not being a standard feature in the specification, I'm hesitant to add it as standard feature in the generator here. Additionally, those validation annotations may specify a message key, which also would need to be resolved first. Through the existing configuration options, you're able to add this yourself though. |
Hi @CarstenWickner, I've encountered the issue discussed here, can you still create an example of how this can be accomplished with the existing configuration options. Thanks! |
Hi @fernandosesma, I've created a basic example and will be adding it to the repository. In order to cover all possible validation annotations, I'm afraid you'll have to do considerable custom configurations. |
Great! This worked like a charm. Thanks so much! |
@CarstenWickner Problem arose when we created the schema with Jakarta Annotations and messages(with Jakarta Module) , no messages were populated in the Json. Thanks for your PR/Example , hopefully we would use this for our use case and will update if it worked. |
Hi developers, annotation like @NotNull(message="xxxxxx") have error message text xxx. Json schema support's message for concrete validation(
"message": {
"maxItems" : "MaxItem must be 3 only",
"type" : "Invalid type"
}
)
Please add options in JavaxValidationOption enum for support error message copy in schema
The text was updated successfully, but these errors were encountered: