Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.