Describe the inspiration for your proposal
Support "errorMessage" for user custom error messages.
Describe the proposal
Keywords like not, then, and else can cause errors where the explanation depends on the library, but they are generally difficult to understand.
Therefore, we need a field that allows JSON Schema creators to provide more specific error messages.
{
"type": "integer",
"minimum": 1,
"errorMessage": {
"type": "value must be an integer.",
"minimum": "value must be greater than or equal to 1."
}
}
Describe alternatives you've considered
Add message values for each error type. However, this method will increase the number of reserved keywords.
{
"type": "integer",
"minimum": 1,
"typeErrorMessage": "value must be an integer.",
"minimumErrorMessage": "value must be greater than or equal to 1."
}
Additional context
This shares a similar background to the deprecationMessage I submitted #1716, but this proposal applies to error messages.
To ensure consistency in the specification, we should start considering these needs as well.
Also, this proposal is based on Ajv-errors and is intended to facilitate an easy transition for some users.
Describe the inspiration for your proposal
Support "errorMessage" for user custom error messages.
Describe the proposal
Keywords like not,
then, andelsecan cause errors where the explanation depends on the library, but they are generally difficult to understand.Therefore, we need a field that allows JSON Schema creators to provide more specific error messages.
{ "type": "integer", "minimum": 1, "errorMessage": { "type": "value must be an integer.", "minimum": "value must be greater than or equal to 1." } }Describe alternatives you've considered
Add message values for each error type. However, this method will increase the number of reserved keywords.
{ "type": "integer", "minimum": 1, "typeErrorMessage": "value must be an integer.", "minimumErrorMessage": "value must be greater than or equal to 1." }Additional context
This shares a similar background to the deprecationMessage I submitted #1716, but this proposal applies to error messages.
To ensure consistency in the specification, we should start considering these needs as well.
Also, this proposal is based on Ajv-errors and is intended to facilitate an easy transition for some users.