> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.fabricgateway.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.fabricgateway.ai/_mcp/server.

# Validator plugin

> Reference for the Validator plugin, which checks request and response fields against rules.

The Validator plugin checks fields of the request, or of the upstream's response, against a list of rules. A rule set fails when any rule fails. On a failure, the plugin denies the request, adds a marker header, or only logs. Validator is a Preview plugin.

> **Note**
>
> On an Enterprise data plane, Validator needs the OPA policy sidecar (`opa.enabled` in the Helm chart), and the data plane must allow Preview plugins with the `global.plugins.allow_preview: true` gateway setting, which is off by default. The Helm chart has no value for this setting. For more information, see [Helm values](/run/helm-values).

## Where it runs

|             |                                                                                                                 |
| ----------- | --------------------------------------------------------------------------------------------------------------- |
| Protocols   | Request rules: all. Response rules: HTTP routes only, for responses that aren't streamed and are at most 1 MiB. |
| Scope kinds | `global`, `service`, `route`. The API also accepts `consumer`, but the console doesn't offer it.                |
| Phase       | Request and response                                                                                            |

## Configuration

**`rules`** `array of objects`

The rules to check.

---

**`rules[].field`** `string` — required

The field to check, for example `request.method`, `request.path`, `request.header.<name>`, `request.query.<name>`, `request.body.<path>`, `response.status`, or `response.body.<path>`. A field that starts with `response.` is a response rule.

---

**`rules[].op`** `string` — required

One of `exists`, `absent`, `eq`, `neq`, `one_of`, `matches`, `glob`, `prefix`, `suffix`, `contains`, `gt`, `gte`, `lt`, `lte`, `between`, `len_lte`, `len_gte`, `format`.

---

**`rules[].value`** `string, number, or boolean`

The operand for a single value. `format` takes `uuid` or `email`. A `matches` pattern can be up to 4,096 characters.

---

**`rules[].values`** `array`

The operands for a rule that needs more than one value. `between` needs two values.

---

**`rules[].message`** `string`

A note stored with the rule. It isn't returned to the client, which gets a generic `validation_failed` error.

---

**`rules[].view`** `string` — default: upstream

For response rules only: check the upstream's response (`upstream`) or the response sent to the client after response plugins ran (`client`).

---

**`on_fail`** `string` — default: deny

`deny` refuses the request. `mark` adds a marker header and continues.

---

**`fail_on_validate`** `boolean` — default: true

Set to `false` for audit mode, which logs failures but never acts on them.

---

**`deny_status`** `number` — default: 422

The status for a request-phase denial, and for a response-phase denial unless `response_deny_status` is set.

---

**`response_deny_status`** `number` — default: 502

The status for a response-phase denial.

---

**`mark_header`** `string` — default: X-Fabric-Validation

The marker header that `mark` adds.

---

**`mark_value`** `string` — default: failed

The value of the marker header.

---

On MCP routes, a denial is a JSON-RPC error with HTTP `200`.

## Example

```json
{
  "name": "orders-validation",
  "plugin_id": "validator",
  "scope": { "kind": "route", "name": "orders-api" },
  "config": {
    "rules": [
      { "field": "request.header.x-request-id", "op": "format", "value": "uuid" },
      { "field": "request.body.quantity", "op": "between", "values": [1, 100] }
    ],
    "on_fail": "deny"
  }
}
```

## Related guides

* [Control traffic with plugins](/configure/plugins)