> For the complete documentation index, see [llms.txt](https://docs.rierino.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rierino.com/extensions/json-schema-extensions.md).

# JSON Schema Extensions

Standard JSON schema is extended mainly for advanced validation use cases

The following keywords can be used in addition to JSON schema standards:

## errorMessage

Supported both on client and server sides, "errorMessage" keyword allows displaying custom error messages when certain validation rules fail. This keyword expects an object outlining messages to display for different types of validation rules, such as:

```json
"title": "Base Price"
"type": "number",
"errorMessage": {
    "type": "Price needs to be numerical",
    "required": "Missing price information"
}
```

## x-validation

On server side, "x-validation" keyword allows applying a set of validation rules to all or select fields at once, such as:

```json
"title": "Product",
"type": "object",
"x-validation": {
    "validator-1": { //label for validator
        "scope": { //either type or fields to apply validation
            "type": "string",
            "fields": ["data.name", "data.surname"]
        },
        "validator": "com.networknt.schema.MinLengthValidator", //validator class
        "props": 3 //props used by the validator
    }
}
```

## x-jmespath

On server side, "x-jmespath" keyword allows applying JMESPath patterns for validating input data. The pattern can either return boolean (false representing invalid data) or an object with valid and message fields, such as:

```json
"title": "Prices",
"type": "object",
"x-jmespath": "basePrice>salePrice"
```

## x-jsoup

On server side, "x-jsoup" keyword allows detection of HTML tags with XSS risk, with the option to select safety level (none, basic, basicWithImages, relaxed or simpleText), such as:

```json
"title": "Description",
"type": "string",
"x-jsoup": "basic"
```

## x-lazy

On server side, "x-lazy" keyword with boolean value allows returning a validation process immediately when a validation error is discovered, skipping evaluation for the remaining rules.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rierino.com/extensions/json-schema-extensions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
