---
id: "es_dni_masked"
kind: "datatype"
status: "draft"
is_pii: true
name: "Spanish identity document number, masked for publication"
regexp: "^(?:\\*{3}\\d{4}\\*{2}|\\*{4}\\d{4}\\*)$"
categories: ["persons", "pii"]
country: ["ES"]
langs: ["common"]
quality: 90
url: "https://registry.apicrafter.io/datatype/es_dni_masked"
---

# Spanish identity document number, masked for publication (`es_dni_masked`)

> **Draft.** Draft records have not been reviewed yet and may be incomplete or wrong; do not treat them as authoritative for legal or compliance decisions.

Number of a Spanish identity document (DNI or NIE) with all but four digits replaced by asterisks, as public bodies publish it next to the name of a person. The data protection law (Ley Orgánica 3/2018, seventh additional provision) asks for four digits of the document, and the guidance of the Spanish data protection authorities picks the digits in positions four to seven, so the DNI 12345678X is written ***4567** and the NIE L1234567X is written ****4567*. The guidance is a recommendation, and registers of contracts and grants also show other positions.

- Parent datatype: [`es_dni`](https://registry.apicrafter.io/datatype/es_dni.md)
- Personal data (PII): yes
- Categories: Person related (persons), Personally identifiable information (pii)
- Countries: Spain (ES)
- Languages: Common to most languages (common)
- Classification: identifier

## Detection

Regular expression (Python `re`):

```
^(?:\*{3}\d{4}\*{2}|\*{4}\d{4}\*)$
```

## Examples

- `***4567**` — the DNI 12345678X of the guidance
- `****4567*` — the NIE L1234567X of the guidance
- `12345678X` (invalid example) — not masked

## Metacrafter rules

1 rules: 0 match the field name, 1 match values.

- `esdnimaskedvalue` (data, `es/es_codes.yaml`)

## Supported by tools

- [`metacrafter`](https://registry.apicrafter.io/tool/metacrafter.md)

## Translations

- es: DNI o NIE anonimizado para su publicación
- ru: Номер документа DNI/NIE

## Sources

- doc: <https://www.aepd.es/documento/orientaciones-da7.pdf>
- doc: <https://www.boe.es/buscar/act.php?id=BOE-A-2018-16673>

## Quality

Score 90/100. Missing: mapping (Wikidata, Schema.org, ...).

JSON: <https://registry.apicrafter.io/api/v1/datatypes/es_dni_masked.json> · Edit: <https://github.com/apicrafter/metacrafter-registry/edit/main/data/datatypes/ES/persons/es_dni_masked.yaml>
