Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions docs/pt-br/utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,32 @@ generateProcessoJuridico({ court: 10 }); // null (órgão inexistente)

Fonte: [Resolução CNJ nº 65/2008](https://atos.cnj.jus.br/atos/detalhar/119).

### getProcessoJuridicoInfo

Lê os campos de um número de processo jurídico, como um `ProcessoJuridicoInfo`, ou `null` quando o `isValidProcessoJuridico` retornaria `false`.

- Campos: `sequentialNumber` (`NNNNNNN`), `checkDigits` (`DD`), `year` (`AAAA`, um número), `segment` (um nome para o órgão `J`: `'supreme-federal-court'`, `'national-council-of-justice'`, `'superior-court-of-justice'`, `'federal'`, `'labor'`, `'electoral'`, `'military'`, `'state'` ou `'state-military'`), `segmentCode` (`J`, `'1'` a `'9'`), `tribunalCode` (`TR`, dois dígitos) e `originUnit` (`OOOO`). Os códigos são strings que mantêm os zeros à esquerda.
- `tribunalCode` é `'00'` para os processos de um tribunal superior ou do STF, do CNJ, do STJ, do TST, do TSE e do STM, `'90'` para o Conselho da Justiça Federal e o Conselho Superior da Justiça do Trabalho, e o número da região ou do estado nos demais casos. A unidade de origem não é verificada: cada tribunal a codifica por conta própria.

```javascript
import { getProcessoJuridicoInfo } from '@brazilian-utils/brazilian-utils';

getProcessoJuridicoInfo('0002080-25.2012.5.15.0049');
// {
// sequentialNumber: '0002080',
// checkDigits: '25',
// year: 2012,
// segment: 'labor',
// segmentCode: '5',
// tribunalCode: '15',
// originUnit: '0049',
// }

getProcessoJuridicoInfo('0000100-23.2008.8.28.0000'); // null (não existe o 28º Tribunal de Justiça)
```

Fonte: [Resolução CNJ nº 65/2008](https://atos.cnj.jus.br/atos/detalhar/119).

## Contas bancárias e bancos

### isValidBankAccount
Expand Down Expand Up @@ -2604,6 +2630,31 @@ generateVoterId('XX'); // usa "ZZ" em vez de lançar erro

Fonte: [Lei nº 14.194/2021, art. 149](https://www.planalto.gov.br/ccivil_03/_ato2019-2022/2021/lei/L14194.htm), a regra de mascaramento do CPF que o `obfuscate` toma emprestada, criada pela [Lei nº 12.309/2010, art. 87, § 5º](https://www.planalto.gov.br/ccivil_03/_ato2007-2010/2010/lei/l12309.htm) e repetida pelas LDOs seguintes (a de 2026, [Lei nº 15.321/2025, art. 163](https://www.planalto.gov.br/ccivil_03/_ato2023-2026/2025/lei/L15321.htm#art163), a repete).

### getVoterIdInfo

Lê os campos de um título de eleitor, como um `VoterIdInfo`, ou `null` quando o `isValidVoterId` retornaria `false`.

- Campos: `sequentialNumber` (8 dígitos), `federativeUnion` (o código `'01'` a `'28'`), `stateCode` (um `StateCode`, ou `null` para `'28'`, os eleitores no exterior) e `checkDigits` (2 dígitos). Os códigos são strings que mantêm os zeros à esquerda.
- Um título expedido sem os zeros à esquerda do número sequencial é lido como o `isValidVoterId` o lê, preenchido com zeros à esquerda até 12 dígitos: `'123450159'` dá o `sequentialNumber` `'00012345'`.
- O `stateCode` é a unidade federativa da inscrição, não necessariamente onde o eleitor mora hoje.

```javascript
import { getVoterIdInfo } from '@brazilian-utils/brazilian-utils';

getVoterIdInfo('1023 8501 06 71');
// {
// sequentialNumber: '10238501',
// federativeUnion: '06',
// stateCode: 'PR',
// checkDigits: '71',
// }

getVoterIdInfo('000000002801'); // { sequentialNumber: '00000000', federativeUnion: '28', stateCode: null, checkDigits: '01' }
getVoterIdInfo('123456780124'); // null (dígitos verificadores inválidos)
```

Fonte: [Resolução TSE nº 23.659/2021, art. 36](https://www.tse.jus.br/legislacao/compilada/res/2021/resolucao-no-23-659-de-26-de-outubro-de-2021).

## CNS

### isValidCns
Expand Down
51 changes: 51 additions & 0 deletions docs/utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,32 @@ generateProcessoJuridico({ court: 10 }); // null (no such órgão)

Source: [Resolução CNJ nº 65/2008](https://atos.cnj.jus.br/atos/detalhar/119).

### getProcessoJuridicoInfo

Read the fields of a processo jurídico number, as a `ProcessoJuridicoInfo`, or `null` when `isValidProcessoJuridico` would return `false`.

- Fields: `sequentialNumber` (`NNNNNNN`), `checkDigits` (`DD`), `year` (`AAAA`, a number), `segment` (a name for the órgão `J`: `'supreme-federal-court'`, `'national-council-of-justice'`, `'superior-court-of-justice'`, `'federal'`, `'labor'`, `'electoral'`, `'military'`, `'state'` or `'state-military'`), `segmentCode` (`J`, `'1'` to `'9'`), `tribunalCode` (`TR`, two digits) and `originUnit` (`OOOO`). Codes are strings that keep their leading zeros.
- `tribunalCode` is `'00'` for the processes of a superior court or of the STF, the CNJ, the STJ, the TST, the TSE and the STM, `'90'` for the Conselho da Justiça Federal and the Conselho Superior da Justiça do Trabalho, and the number of the region or state otherwise. The unit of origin is not checked: each tribunal codifies its own.

```javascript
import { getProcessoJuridicoInfo } from '@brazilian-utils/brazilian-utils';

getProcessoJuridicoInfo('0002080-25.2012.5.15.0049');
// {
// sequentialNumber: '0002080',
// checkDigits: '25',
// year: 2012,
// segment: 'labor',
// segmentCode: '5',
// tribunalCode: '15',
// originUnit: '0049',
// }

getProcessoJuridicoInfo('0000100-23.2008.8.28.0000'); // null (no 28th Tribunal de Justiça)
```

Source: [Resolução CNJ nº 65/2008](https://atos.cnj.jus.br/atos/detalhar/119).

## Bank accounts and banks

### isValidBankAccount
Expand Down Expand Up @@ -2604,6 +2630,31 @@ generateVoterId('XX'); // falls back to "ZZ" instead of throwing

Source: [Lei nº 14.194/2021, art. 149](https://www.planalto.gov.br/ccivil_03/_ato2019-2022/2021/lei/L14194.htm), the CPF masking rule `obfuscate` borrows, first set by [Lei nº 12.309/2010, art. 87, § 5º](https://www.planalto.gov.br/ccivil_03/_ato2007-2010/2010/lei/l12309.htm) and repeated by the later LDOs ([Lei nº 15.321/2025, art. 163](https://www.planalto.gov.br/ccivil_03/_ato2023-2026/2025/lei/L15321.htm#art163), the one for 2026, repeats it).

### getVoterIdInfo

Read the fields of a voter ID, as a `VoterIdInfo`, or `null` when `isValidVoterId` would return `false`.

- Fields: `sequentialNumber` (8 digits), `federativeUnion` (the code `'01'` to `'28'`), `stateCode` (a `StateCode`, or `null` for `'28'`, the voters abroad) and `checkDigits` (2 digits). Codes are strings that keep their leading zeros.
- A voter ID issued without the leading zeros of its sequential number is read as `isValidVoterId` reads it, left padded with zeros to 12 digits: `'123450159'` gives the `sequentialNumber` `'00012345'`.
- The `stateCode` is the federative union of the registration, not necessarily where the voter lives today.

```javascript
import { getVoterIdInfo } from '@brazilian-utils/brazilian-utils';

getVoterIdInfo('1023 8501 06 71');
// {
// sequentialNumber: '10238501',
// federativeUnion: '06',
// stateCode: 'PR',
// checkDigits: '71',
// }

getVoterIdInfo('000000002801'); // { sequentialNumber: '00000000', federativeUnion: '28', stateCode: null, checkDigits: '01' }
getVoterIdInfo('123456780124'); // null (invalid check digits)
```

Source: [Resolução TSE nº 23.659/2021, art. 36](https://www.tse.jus.br/legislacao/compilada/res/2021/resolucao-no-23-659-de-26-de-outubro-de-2021).

## CNS

### isValidCns
Expand Down
2 changes: 2 additions & 0 deletions jsr.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"./get-nfse-key-info": "./src/get-nfse-key-info/get-nfse-key-info.ts",
"./get-pix-key-info": "./src/get-pix-key-info/get-pix-key-info.ts",
"./get-pix-payload-info": "./src/get-pix-payload-info/get-pix-payload-info.ts",
"./get-processo-juridico-info": "./src/get-processo-juridico-info/get-processo-juridico-info.ts",
"./get-regions": "./src/get-regions/get-regions.ts",
"./get-service-item": "./src/get-service-item/get-service-item.ts",
"./get-state-by-cep": "./src/get-state-by-cep/get-state-by-cep.ts",
Expand All @@ -103,6 +104,7 @@
"./get-states": "./src/get-states/get-states.ts",
"./get-states-by-region": "./src/get-states-by-region/get-states-by-region.ts",
"./get-timezone-by-state": "./src/get-timezone-by-state/get-timezone-by-state.ts",
"./get-voter-id-info": "./src/get-voter-id-info/get-voter-id-info.ts",
"./is-business-day": "./src/is-business-day/is-business-day.ts",
"./is-holiday": "./src/is-holiday/is-holiday.ts",
"./is-valid-bank-account": "./src/is-valid-bank-account/is-valid-bank-account.ts",
Expand Down
12 changes: 12 additions & 0 deletions src/get-processo-juridico-info/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** Segments of the Judiciary, in the order of the órgão digit `J` (1 to 9, Resolução CNJ nº 65/2008, art. 1º, § 4º). */
export const PROCESSO_JURIDICO_SEGMENTS = [
"supreme-federal-court",
"national-council-of-justice",
"superior-court-of-justice",
"federal",
"labor",
"electoral",
"military",
"state",
"state-military",
] as const;
Loading
Loading