-
-
Notifications
You must be signed in to change notification settings - Fork 354
Closed
Description
Originally written by @epoberezkin at https://github.com/json-schema/json-schema/wiki/Custom-error-messages-(v5-proposal)
with additional requests by @the-t-in-rtf at json-schema/json-schema#222
Add keyword errors
that would contain error messages, potentially templated, that would be added to errors reported by validators when some keyword fails the validation. Example:
{
"properties": {
"age": {
"minimum": 13,
"errors": {
"minimum": "Should be at least ${schema} years, ${data} years is too young."
}
},
"gender": {
"enum": ["male", "female"],
"errors": {
"enum": {
"text": "Gender should be ${schema/0} or ${schema/1}",
"action": "replace"
}
}
}
}
}
They can be merged using absolute or relative JSON pointers:
{
"properties": {
"age": { "minimum": 13 },
"gender": { "enum": ["male", "female"] }
},
"errors": {
"#/properties/age/minimum": "Should be at least ${schema} years, ${data} years is too young.",
"#/properties/gender/enum": {
"text": "Gender should be ${schema/0} or ${schema/1}",
"action": "replace"
}
}
}
Metadata
Metadata
Assignees
Labels
No labels