# Validate a Policy Set

Errors that stop a submission, and warnings that don't. Changes nothing.

## Overview

- Any version can be validated. `valid` is `true` when there is no error. Each finding has its `code`, the rule's `position` (`null` for the set as a whole) and a `message`. The codes: [Validate and Simulate](https://docs.aureahub.com/docs/guide-policy-sets.md).
- Submitting validates again: a set with an error answers `422` `POLICY_SET_INVALID`.
- `ADDRESS_BOOK_NOT_OBSERVED` is a warning, never an error: a rule naming the destination kind `address_book` while your tenant's [address book](https://docs.aureahub.com/docs/guide-address-book.md) is off matches no destination by that kind. Every tenant's book is in `log` today.

## Endpoint

### `POST /v1/policy-sets/{setId}/validate`

Authentication: bearer token required.

Validates a policy set. No body.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `setId` | string | yes | The set's id |

**Responses**

`200` Valid

```json
{
  "valid": true,
  "ruleCount": 3,
  "errors": [],
  "warnings": []
}
```

`200` Empty draft

```json
{
  "valid": true,
  "ruleCount": 0,
  "errors": [],
  "warnings": [
    {
      "code": "EMPTY_SET",
      "position": null,
      "message": "The set has no rule: a legacy tenant's default allows every operation, the institutional default blocks every one."
    }
  ]
}
```

`200` Address book off

```json
{
  "valid": true,
  "ruleCount": 2,
  "errors": [],
  "warnings": [
    {
      "code": "ADDRESS_BOOK_NOT_OBSERVED",
      "position": 0,
      "message": "Rule 0 names the destination kind address_book, but the tenant's address book is off: until it is in log or enforce, no destination is read as address_book."
    }
  ]
}
```

---

Web version: https://docs.aureahub.com/#policy-set-validate
