To include a minimum/maximum length requirement in the error message for JSON schema, you can use the "minLength" and "maxLength" keywords along with the "errorMessage" keyword. For example:
{
"type": "string",
"minLength": 5,
"maxLength": 20,
"errorMessage": {
"minLength": "The value must be at least 5 characters long",
"maxLength": "The value cannot be longer than 20 characters"
}
}
Here, the "errorMessage" keyword is an object that specifies custom error messages for the "minLength" and "maxLength" keywords. When a JSON object fails to satisfy the minimum/maximum length requirement, the corresponding error message will be displayed.
Asked: 2022-03-24 11:00:00 +0000
Seen: 11 times
Last updated: Jun 03 '21