> For the complete documentation index, see [llms.txt](https://docs.griaule.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.griaule.com/gbs/es/configuracion-del-gbds/validacion-de-claves.md).

# Validación de claves

A partir do GBDS 5 foram adicionadas novas configurações na API

<table><thead><tr><th width="261.727294921875">Configuração</th><th>Valor Padrão</th></tr></thead><tbody><tr><td>gbds.keyValidation.oneKeyOnly</td><td>false</td></tr><tr><td>gbds.keyValidation.keyFormat</td><td>false</td></tr><tr><td>gbds.keyValidation.inconsistentKeys</td><td>true</td></tr></tbody></table>

## Comportamento

### Validação de chave única

A API rejeitará qualquer transação que possua mais de uma chave (enroll, update, trusted enroll e trusted update)

### Validação de formato de chave

A API rejeitará qualquer transação cujas chaves não passarem na validação de formato.

A API irá avaliar o formato na tabela `gbds.key_format` para cada ID de chave fornecida

A API irá checar os seguintes:

| Tipo         | Validação                                                                         |
| ------------ | --------------------------------------------------------------------------------- |
| CPF          | Deve passar a validação de soma para CPF                                          |
| TITULO       | Deve passar a validação de soma para o título                                     |
| REGEX        | Deve passar o regex fornecido no campo `regex`                                    |
| ALPHANUMERIC | Chave deve possuir apenas caracteres alfa numéricos                               |
| NUMERIC      | Chave deve possuir apenas caracteres numéricos                                    |
| ALPHABETIC   | Chave deve possuir apenas caracteres alfabéticos                                  |
| LENGTH       | Caso seja configurado um tamanho mínimo/máximo, a chave terá seu tamanho validado |

### Chaves Inconsistentes

Quando essa configuração está ativada, a transação será rejeitada em enroll/update/trusted com chaves potencialmente inconsistentes quando uma atualização for executada

Casos de chaves inconsistentes:

* Se o payload for fornecido com mais de uma chave e essas chaves coincidirem com mais de uma pessoa

| IDs       | Chaves no Payload | Pessoa 1 na Database | Pessoa 2 na Database |
| --------- | ----------------- | -------------------- | -------------------- |
| ***cpf*** | cpf-01            | cpf-01               | -                    |
| ***rg***  | rg-01             | -                    | rg-01                |

* Se o payload for fornecido com mais de uma chave e uma chave coincidir com a chave de uma pessoa mas essa pessoa possui qualquer outra chave com ID que coincide com outra chave no payload, mas com valor diferente.

| IDs       | Chaves no Payload | Pessoa na Database |
| --------- | ----------------- | ------------------ |
| ***cpf*** | cpf-01            | cpf-01             |
| ***rg***  | rg-01             | rg-02              |

O id "rg" coincide no payload e na pessoa na database, mas ambos tem valores diferentes

{% hint style="info" %}
Com a configuração desativada, a transação acima irá gerar uma exceção como ocorre no GBDS 4
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.griaule.com/gbs/es/configuracion-del-gbds/validacion-de-claves.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
