Open ghost opened 3 years ago
I want to output the error message defined by myself:
schema.json
{ "$schema": "https://json-schema.org/draft/2019-09/schema", "type": "object", "title": "test", "properties": { "name": { "type": "string", "pattern": "^[a-z]$", "description":"err msg" } } }
document.json
{ "name": "123" }
https://github.com/xeipuuv/gojsonschema/blob/master/locales.go#L316-L318
When the regular matching is wrong,how can I output the information in description?Thank you!
We are trying to model various validation steps using
not
,oneOf
,anyOf
,andallOf
conditions. When the data does not pass schema validation, we get errors such as:I was thinking it would be helpful to include the "description" and or "title" annotations (if they exist) from the supplied schema in the error message. Is this a reasonable solution that would work well for all users? I can submit a PR if you think that is the right direction to move in.
I am an indirect user of this library (I have a Helm chart, and Helm uses gojsonschema). As such, I don't have options to plug in a custom locale supplying overrides of the error messages.
Thank you for your work on this library! It's very helpful to us... and please accept my apologies for the near-certainty that I misused JSON Schema terminology... I am still somewhat new. 😄