# Validation rules

> Every rule the registry validator can report, what it means, and how to fix it.

Every rule the registry validator can report, what it means, and how to fix it. Rule ids are stable: tools and tests may match on them.

A validation error has a `rule`, a `path` (a JSON pointer into the registry, such as `/artefacts/2/processor`; `""` is the document root), a `message` that says what is wrong and how to fix it, and, when the path resolves to a YAML node, a 1-based `line` and `column`.

Validation runs in two passes. The structure is checked first (`yaml/*` and `schema/*`, plus the few shape rules with a name of their own). The semantic rules only run once the structure is sound, so fixing a structural error can reveal semantic ones.

A registry that does not validate fails `check`, `build`, `docs` and `release` with exit code 1. `diff` and `script-tag` print the errors and exit 1 as well.

## Structure

| Rule | Meaning | Fix |
| --- | --- | --- |
| `yaml/syntax` | The file is not well-formed YAML. | Fix the syntax at the reported line. |
| `schema/type` | A value has the wrong JSON type. | Use the type the message names. |
| `schema/required` | A required field is missing. | Add the field. See the [registry reference](/docs/manual/reference/registry/). |
| `schema/unknown-property` | A field is not part of the registry format. | Remove it or fix the spelling. The format has no extension fields. |
| `schema/enum` | A value is not one of the allowed options. | Use one of the options the message lists. |
| `schema/format` | A value does not have the expected shape: an empty string, an empty or duplicated list item, a malformed country code, locale or reporting group name, a `dpo` that is neither `false` nor an object with `contact`. | Follow the message. |
| `schema/id-format` | An id is not lowercase and does not match `^[a-z][a-z0-9_-]*$`. | Rename it: start with a letter, then letters, digits, `_` or `-`. |
| `schema/exactly-one-of` | Exactly one of two alternative fields must be set: `name` or `pattern` on a cookie, `key` or `pattern` on a storage artefact, `endpoint` or `optOut` under `receipts`. | Keep one of the two. |

## Ids and locales

| Rule | Meaning | Fix |
| --- | --- | --- |
| `id/duplicate` | Two entries of the same section (`purposes`, `processors`, `artefacts`, `collectionPoints`) share an id. | Rename one of them. |
| `locale/default-not-declared` | `defaultLocale` is not listed in `locales`. | Add it to `locales` or pick a declared locale. |
| `locale/missing-text` | A localized text lacks one of the declared locales. | Add the text in that locale. Every localized text must cover all of `locales`. |
| `locale/undeclared-text` | A localized text uses a locale that is not in `locales`. | Add the locale to the top-level list or remove the text. |

## Controller

| Rule | Meaning | Fix |
| --- | --- | --- |
| `controller/dpo-not-stated` | The controller neither names a data protection officer nor states that there is none. | Add `dpo: { contact: <email or address> }` (name optional), or `dpo: false`. |
| `controller/missing-supervisory-authority` | The controller names no supervisory authority, which the privacy policy needs for the right to lodge a complaint. | Add `supervisoryAuthority: { name: <authority>, url: <its website> }`. |

## Purposes

| Rule | Meaning | Fix |
| --- | --- | --- |
| `purpose/reserved-id` | A purpose uses the id `necessary`, which the banner reserves for its read-only group. | Rename the purpose, for example to `essential`. |
| `purpose/consent-default-not-denied` | A consent purpose has `default: granted`. Consent must be opt-in. | Set `default: denied` or remove `default`. |
| `purpose/default-on-non-consent` | `default` is set on a purpose whose basis is not consent. Such a purpose has no toggle. | Remove `default`, or change the basis to `consent`. |
| `purpose/invalid-retention` | `retention` is not `session`, `until-withdrawn`, `<n>d` or `<n>d-after-<event>`. | Use one of the four forms. |
| `purpose/vague-text` | The description of a consent purpose is nothing more than a stock phrase such as "marketing purposes", "analytics" or "improving user experience". The match is conservative: the text is lower-cased, stripped of punctuation and filler words, and must then equal a listed phrase in full. | Say what is done, with which data, and why. |
| `purpose/missing-legitimate-interest` | A purpose with `basis: legitimate_interest` does not state the interest pursued (Art. 13(1)(d) GDPR). | Add `legitimateInterest` with one text per locale. |
| `purpose/legitimate-interest-on-other-basis` | `legitimateInterest` is set on a purpose with another basis; no document would print it. | Remove it, or change the basis. |
| `purpose/adm-not-stated` | A purpose does not say whether automated decision-making, including profiling, takes place (Art. 13(2)(f) GDPR). | Add `automatedDecisionMaking: false`, or `{ logic: {…}, consequences: {…} }`. |
| `purpose/missing-data-subjects` | A purpose names no category of data subjects (Art. 30(1)(c) GDPR). | Add `dataSubjects` with at least one id, for example `[visitors]`. |
| `purpose/unknown-data-subject` | A purpose uses a data subject category that the `dataSubjectCategories` map does not declare. Only reported when the map exists. | Declare the id in the map, or use a declared one. |
| `purpose/unknown-data-category` | A purpose uses a data category that the `dataCategories` map does not declare. Only reported when the map exists. | Declare the id in the map, or use a declared one. |
| `purpose/unknown-retention-event` | A retention such as `30d-after-closed` refers to an event that the `retentionEvents` map does not declare. Only reported when the map exists. | Declare the event in the map. |
| `purpose/unknown-processor` | A purpose lists a processor id under `processors` that is not declared. | Declare the processor, or fix the id. |

## Processors

| Rule | Meaning | Fix |
| --- | --- | --- |
| `processor/missing-transfer-mechanism` | A processor's `country` is outside the EU/EEA and it has no `transferMechanism`. | Set `transferMechanism` to `adequacy`, `scc`, `dpf` or `bcr`. |
| `processor/unreferenced` | A processor is used by no artefact and listed by no purpose, so no document can say what it receives data for. Not reported next to a reference to an undeclared processor, which is most likely this one misspelt. | Set `processor: <id>` on its artefacts, add it to `processors` of the purposes whose data it receives, or remove it. |

## Artefacts

| Rule | Meaning | Fix |
| --- | --- | --- |
| `artefact/no-purpose` | An artefact is not bound to any purpose. | Add `purposes` with at least one purpose id. |
| `artefact/unknown-purpose` | An artefact references a purpose that is not declared. | Declare the purpose, or fix the id. |
| `artefact/unknown-processor` | An artefact references a processor that is not declared. | Declare the processor, or fix the id. |
| `artefact/third-party-without-processor` | An artefact loads from or sends to an absolute `http(s)` URL (including `//host/…`) and has no `processor`. | Declare the vendor under `processors` and set `processor` to its id. |
| `artefact/invalid-pattern` | The `pattern` of a cookie or storage artefact is not a valid regular expression. | Fix the expression, or use `name` / `key` for an exact match. |
| `artefact/unsupported-url` | An artefact URL is not an `http(s)` URL or a site-relative path starting with `/`, or it contains a backslash, whitespace or a control character, which browsers rewrite or strip. | Write a URL such as `https://cdn.example/tag.js`, or a path such as `/js/app.js`. |
| `artefact/consent-not-enforceable` | A `stylesheet`, `font` or `media` artefact is bound to a consent purpose. Nothing can hold it back until consent: the banner only manages `<script>` tags, the guard does not see `<link>`, CSS `url()` or `<video>` loads, and the Content-Security-Policy is the same before and after a decision. | Host the file yourself (then it needs no declaration), bind it to a purpose with another lawful basis that you can defend, or load it from a consent-gated script. |
| `script/multiple-consent-purposes` | A script is bound to more than one consent purpose, but the banner can gate a script on only one. | Bind it to a single consent purpose, or split it into one script per purpose. |
| `cookie/invalid-duration` | A cookie `duration` is not `session` or `<n>d`. | Use `session` or a number of days such as `365d`. |
| `storage/invalid-duration` | A storage `duration` is not `persistent` or `<n>d`. | Use `persistent` or a number of days, or remove the field. |

## Collection points

| Rule | Meaning | Fix |
| --- | --- | --- |
| `collection-point/duplicate-field` | A collection point declares the same field name twice. | Keep one entry per field. |
| `collection-field/no-purpose` | A field has no purpose. | Add `purpose`. |
| `collection-field/unknown-purpose` | A field references a purpose that is not declared. | Declare the purpose, or fix the id. |
| `collection-field/missing-provision` | A field does not say whether providing it is required (Art. 13(2)(e) GDPR). | Add `provision: statutory`, `contractual` or `voluntary`. |
| `collection-field/missing-consequence` | A statutory or contractual field does not say what happens when it is not provided. | Add `consequence` with one text per locale. |

## Content-Security-Policy

| Rule | Meaning | Fix |
| --- | --- | --- |
| `csp/unknown-directive` | A `csp.allow` entry names a directive consent-kit does not generate or that cannot be loosened. | Use one of the directives listed in the [registry reference](/docs/manual/reference/registry/#csp). |
| `csp/invalid-source` | A `csp.allow` source is not a well-formed source expression. The usual cause is a keyword without its quotes, which a browser would read as a host name. | Write one source per list item, exactly as it appears in the header: `"'unsafe-inline'"`, `"data:"`, `"https://cdn.example"`. |
| `csp/redundant-source` | A source is `'none'`, which allows nothing and so cannot loosen a directive, or it repeats what an earlier `csp.allow` entry already allows for the same directive. | Remove it. Keep one entry, with one reason. |
| `csp/invalid-report-uri` | `csp.reportUri` is not an `http(s)` URL or a site-relative path, is written in a way browsers read differently, or contains `;`, `,` or a double quote. | Write a URL, or a path such as `/csp-reports`. |
| `csp/undeclared-report-endpoint` | `csp.reportUri` sends every violation report, with the visitor's IP address and the page URL, to a third party that no `endpoint` artefact declares. | Add an `endpoint` artefact for it, with its processor and a purpose. |

## Consent receipts

| Rule | Meaning | Fix |
| --- | --- | --- |
| `receipts/not-stated` | A purpose is based on consent, but the registry does not say where the proof of each decision goes or that it keeps none. | Add `receipts: { endpoint: /consent-receipts }`, or `receipts: { optOut: { reason: <why> } }`. |
| `receipts/invalid-endpoint` | `receipts.endpoint` is not a site-relative path or an `https:` URL, or is written in a way browsers read differently. | Write a path such as `/consent-receipts`, or an `https:` URL. |
| `receipts/undeclared-endpoint` | `receipts.endpoint` points at a third party that no `endpoint` artefact declares. | Add an `endpoint` artefact whose `url` covers it, with its processor and a purpose that is not based on consent. |
| `receipts/endpoint-needs-consent` | The `endpoint` artefact that covers `receipts.endpoint` (the longest matching prefix) is bound to a consent purpose. A receipt is sent for a rejection too, so its endpoint cannot wait for consent. | Bind that artefact to a purpose with another lawful basis, or declare a separate endpoint artefact for the receipts. |
| `receipts/vague-reason` | The reason given for `receipts.optOut` is a stock non-reason ("n/a", "not needed", "TODO", "later") or says nothing. | Say why the site can do without proof of its visitors' decisions: where else they are recorded, or the ticket that tracks adding an endpoint. |

## Subject requests

| Rule | Meaning | Fix |
| --- | --- | --- |
| `subject-requests/endpoint-not-same-origin` | `subjectRequests.endpoint` is not a site-relative path, has a query or fragment, or is written in a way browsers read differently. On another origin the browser would not send the consent cookie, so the request could not be tied to its receipts. | Write a path such as `/privacy/requests` and route it to the handler on the site's own domain. |
| `subject-requests/unknown-type` | `subjectRequests.types` lists something other than `access` or `erasure`. | Remove it. Other requests still reach the controller's contact. |
| `subject-requests/retention-format` | `subjectRequests.retention` is not `<n>d` or `<n>y`. | Write how long a closed request is kept, e.g. `3y` or `400d`. |
| `subject-requests/unknown-processor` | `subjectRequests.requesterEmail.processor` is not a declared processor. | Declare the email provider under `processors`, or fix the id. |
| `subject-requests/invalid-notify` | `subjectRequests.notify` is not an email address. | Write the mailbox, e.g. `privacy@example.com`. |
| `subject-requests/purpose-id-taken` | A purpose uses the id `subject-requests`, which the section adds as a built-in purpose. | Rename the purpose, or remove it and let the built-in one describe the handling of requests. |

## Imprint

| Rule | Meaning | Fix |
| --- | --- | --- |
| `imprint/missing-controller-address` | `imprint` is declared, but `controller.address` is not set. An imprint must give the postal address at which the provider is established (§ 5 (1) no. 1 DDG). | Add `address` under `controller`: street and number, postcode, city. A P.O. box is not enough. |
| `imprint/contact-not-email` | `imprint` is declared, but `controller.contact` is not an email address, which an imprint must give (§ 5 (1) no. 2 DDG). | Write the mailbox in `controller.contact`, e.g. `hello@example.com`. |
| `imprint/invalid-phone` | `imprint.phone` has characters other than digits, spaces, `+`, `-`, `/`, `.` and parentheses, or fewer than 6 digits. | Write the number with its country code, e.g. `+49 30 1234567`. |
| `imprint/invalid-contact-form` | `imprint.contactForm` is not an `http(s)` URL or a site-relative path starting with `/`, or contains a backslash, whitespace or a control character. | Write a path such as `/contact`, or an `https:` URL. |
| `imprint/invalid-vat-id` | `imprint.vatId` is not a two-letter country prefix followed by 2 to 13 letters or digits. | Write the number without spaces, e.g. `DE123456789`. |
## Presets

| Rule | Meaning | Fix |
| --- | --- | --- |
| `preset/unresolved` | The registry uses presets, but the validator was given no preset catalogue. The `consent-kit` CLI never reports this; a tool that calls `@consent-kit/schema` directly can. | Use `parseRegistry` / `validateRegistry` from `@consent-kit/presets` or `@consent-kit/cli`, or pass `{ presets: catalogue }`. |
| `preset/unknown` | A `presets` entry names a preset or a version the catalogue does not have. | Use an id and version the message lists. |
| `preset/purpose` | A purpose slot is not mapped, the slot does not exist, the purpose is not declared, or both `purpose` and `purposes` are set. | Map every slot to one of your purpose ids. |
| `preset/parameter` | A parameter under `with` is missing, unknown, or of the wrong shape (for example an origin with a path). | Supply every parameter that has no default, in the documented shape. |
| `preset/id-collision` | An id the preset expands to is already used by a hand-written entry or by another preset. Nothing is merged. | Remove the hand-written entry, or rename under `ids`. |
| `preset/override` | An `ids`, `exclude` or `overrides` entry names something the preset does not have, tries to change `id` or `kind`, or both excludes and overrides one artefact. | Use the preset's default ids; see the [presets reference](/docs/manual/reference/presets/). |

An error about an entry that a preset expanded is reported at the `presets` entry it came from, because the expanded entry has no line in your file.

## Preset warnings

These never fail validation. `consent-kit check` prints them as warnings.

| Code | Meaning |
| --- | --- |
| `preset/basis-mismatch` | A slot is bound to a purpose whose lawful basis differs from the one the preset expects. The basis is your decision; consent-kit never changes it for you. |
| `preset/redundant-override` | An override equals the preset's own value. |
| `preset/missing-locale` | The preset has no text in one of your locales; the artefact gets no description until you supply one under `overrides`. |

## Findings that are not validation errors

`consent-kit check` reports a second family of codes, about the changes since the last release rather than the registry itself: `version/missing_bump`, `review/unacknowledged`, `confirmation/unacknowledged`, `receipts/opted-out` and others. They are listed in the [CLI reference](/docs/manual/reference/cli/#findings).
