alvarofpp / alvarofpp/validate-docbr

TituloEleitoral.validate() aceita identificador de UF inexistente

Đang mở
#82 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Python
Star
484
Fork
54
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

`TituloEleitoral.validate()` confere apenas o tamanho (12 dígitos) e os dois dígitos verificadores. O identificador de UF (9º e 10º dígitos) não é validado, então qualquer par de dígitos passa — inclusive `00`, `29` e `99`, que não existem na tabela da [Resolução TSE 23.659/2021, Art. 36](https://www.tse.jus.br/legislacao/compilada/res/2021/resolucao-no-23-659-de-26-de-outubro-de-2021) (UFs válidas: `01` a `28`).

## Como reproduzir

```python
from validate_docbr import TituloEleitoral

t = TituloEleitoral()
t.validate('100000010000') # UF 00 -> True
t.validate('100000012909') # UF 29 -> True
t.validate('100000019903') # UF 99 -> True
```

Os três têm dígitos verificadores corretos, mas a UF é inexistente.

## Solução proposta

Rejeitar em `validate()` documento cujo identificador de UF esteja fora de `01`–`28`.

## Atenção: mudança incompatível

A correção rejeita entrada que hoje é aceita, então é *breaking change* — precisa entrar em release major (ou ficar atrás de um parâmetro opcional, a definir).

Encontrado durante a apuração da #70. Relacionado com a #81.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.