# Validation & limits

These constraints apply to `patterns`, `suggestions`, `context_include`, `context_exclude`, and `description`.

### Forbidden characters

Forbidden characters are validated per-field.

| Field(s)                                                        | Forbidden characters                                                                       | Notes                                            |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------ |
| `patterns`, `suggestions`, `context_include`, `context_exclude` | `#` `;` `[` `]` `<` `>` `{` `}` and control characters: `\n` `\t` `\b` `\r` `\a` `\f` `\v` | Control characters are rejected even if escaped. |
| `description`                                                   | `#` `[` `]` `<` `>` `{` `}` and control characters: `\n` `\t` `\b` `\r` `\a` `\f` `\v`     | Same as above, but `;` is allowed.               |

### Allowed characters

Allowed characters are validated per-field. All the not-lister characters are forbidden.

| Field(s)                       | Allowed characters                                                                                                                    | Notes |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| `collection`, `new_collection` | <p><code>\[a-z]</code>; <code>\[A-Z]</code>; <code>\[0-9]</code> ;<br><code>’ ‘</code> (space);<br><code>‘-’</code> (HyphenMinus)</p> |       |

### Length limits

Limits are Unicode character count.

The limit is the **total length across all values** when the field is an array.

| Field                          | Max length (Unicode chars) | Notes                                                |
| ------------------------------ | -------------------------- | ---------------------------------------------------- |
| `patterns`                     | 150                        | If this is an array, sum of all items must be ≤ 150. |
| `suggestions`                  | 150                        | If this is an array, sum of all items must be ≤ 150. |
| `context_include`              | 150                        | If this is an array, sum of all items must be ≤ 150. |
| `context_exclude`              | 150                        | If this is an array, sum of all items must be ≤ 150. |
| `description`                  | 200                        | Always checked as a single string.                   |
| `collection`, `new_collection` | 250                        | Always checked as a single string.                   |

### Uniqueness and cross-field rules

| Constraint                                | What it means                                                                                            |
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| Unique `patterns`                         | All `patterns` values must be unique within a rule.                                                      |
| Unique `suggestions`                      | All `suggestions` values must be unique within a rule.                                                   |
| Pattern vs suggestion collision           | A `patterns` value cannot equal any `suggestions` value.                                                 |
| Context vs pattern collision (`include`)  | No `context_include` item may equal any `patterns` item.                                                 |
| Context vs pattern collision (`exclude`)  | No `context_exclude` item may equal any `patterns` item.                                                 |
| Include vs exclude collision              | No `context_exclude` item may equal any `context_include` item.                                          |
| No substring overlap in `context_include` | No `context_include` value may be a substring of another `context_include` value.                        |
| No substring overlap in `context_exclude` | No `context_exclude` value may be a substring of another `context_exclude` value.                        |
| Rule-level duplication in a file          | Two rules with the same `patterns` + `context_include` combination are not allowed within the same file. |
| Unique `collection`,`new_collection`      | `collection` must be case-insensitive unique name per language.                                          |

### Limits

| Limit                      | Value     |
| -------------------------- | --------- |
| Maximum rules per language | **2,000** |


---

# Agent Instructions: 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.wproofreader.com/api-reference/style-guide-api/validation-and-limits.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.
