> For the complete documentation index, see [llms.txt](https://docs.lingoql.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lingoql.com/sub0/apis-abi/payload-validation.md).

# Payload Validation

Payload validation runs before an actionable executes.

If validation fails, the actionable stops and returns an error.

### Enable validation

Add validation rules to an actionable:

```json
"payload_validation": [ ... ]
```

Skip validation only when the data is already trusted:

```json
"bypass_payload_validation": true
```

### Supported types

| Type          | Use for           |
| ------------- | ----------------- |
| `STRING`      | Text values       |
| `NUMBER`      | Numeric values    |
| `EMAIL`       | Email addresses   |
| `OBJECT`      | Nested objects    |
| `ARRAY`       | Arrays of objects |
| `STRINGARRAY` | Arrays of strings |

### Rule fields

| Property           | Purpose                    |
| ------------------ | -------------------------- |
| `field`            | Field to validate          |
| `min_length`       | Minimum length             |
| `max_length`       | Maximum length             |
| `arr_length`       | Array length               |
| `items_min_length` | Min length per string item |
| `items_max_length` | Max length per string item |
| `fields`           | Nested field rules         |

### Simple examples

#### Email

```json
{
  "field": {
    "email": {
      "type": "EMAIL"
    }
  },
  "min_length": 5,
  "max_length": 255
}
```

#### Number

```json
{
  "field": {
    "age": {
      "type": "NUMBER"
    }
  }
}
```

#### Object

```json
{
  "field": {
    "phone": {
      "type": "OBJECT",
      "fields": {
        "code": {
          "type": "STRING",
          "min_length": 1,
          "max_length": 5
        },
        "number": {
          "type": "STRING",
          "min_length": 5,
          "max_length": 15
        }
      }
    }
  }
}
```

#### String array

```json
{
  "field": {
    "hobbies": {
      "type": "STRINGARRAY",
      "arr_length": 5,
      "items_min_length": 2,
      "items_max_length": 50
    }
  }
}
```

### What to expect

1. Sub0 receives the payload.
2. Rules run before the actionable.
3. Invalid payloads fail fast.
4. Valid payloads continue to the query or request.

### Why it matters

Validation keeps bad input out of your database and workflows.

That gives you cleaner APIs with less defensive code.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lingoql.com/sub0/apis-abi/payload-validation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
