Court case number
Court case numbers in the unified numbering of Resolução CNJ nº 65/2008 (NUP).
Validate
- JavaScript library
- Python library25 cases fail
- Go library22 cases fail
- Ruby library22 cases fail
- Rust library22 cases fail
- .NET library22 cases fail
- Erlang library
Validates a court case number (Resolução CNJ nº 65/2008). It checks the NNNNNNN-DD.AAAA.J.TR.OOOO layout, the DD check digits (ISO 7064 MOD 97-10) and the J/TR pair.
JandTRmust name a segment and a tribunal that exist (art. 1º, §§ 4º and 5º).Jis 1 (STF), 2 (CNJ), 3 (STJ), 4 (Justiça Federal), 5 (Justiça do Trabalho), 6 (Justiça Eleitoral), 7 (Justiça Militar da União), 8 (Justiça Estadual) or 9 (Justiça Militar Estadual).TRis00forJ1, 2 and 3; forJ4,01to06(TRF) or90(CJF); forJ5,00(TST),01to24(TRT) or90(CSJT); forJ6,00(TSE) or01to27(TRE); forJ7,00(STM) or01to12(CJM); forJ8,01to27(TJ); forJ9,13,21or26(TJM of MG, RS and SP).- The unidade de origem
OOOOis only checked as four digits, because art. 1º, § 6º leaves its codification to each tribunal. - Accepts the 20 digits bare or with the CNJ mask, and only a string (a number is invalid). Whitespace,
.,-and/(the mask characterscpf.isValidreads), in any run, are accepted between theNNNNNNN,DD,AAAA,J,TRandOOOOfields, or omitted, so0002080-25.2012.515.0049(JandTRfused) is valid. Whitespace around the value is ignored. A separator inside a field (000208-0252012.5.15.0049), at the start or the end of the value, any other character (_) and a letter make it invalid. Until 2.4.0 a slash between the fields made it invalid, so0002080/25.2012.5.15.0049wasfalse. - The check digits follow art. 1º § 2º and Anexo VIII ("Cálculo do dígito verificador") of Resolução CNJ 65/2008. The TRF da 6ª Região (
4.06) is valid per Resolução CNJ 477/2022. - The TRF6 example printed in Anexo II,
0000100-15.2008.406.0000, is fictitious, as the Anexo says. Written in theNNNNNNN-DD.AAAA.J.TR.OOOOform its check digits are 68, not 15, so the function accepts0000100-68.2008.4.06.0000and rejects the printed one.
Pending decision
Go, Python, Ruby and Rust reject numbers that the reference (JS) generates for the current year. The segment/tribunal rules need to be reconciled. See the open decision in docs/findings.md.
| Parameter | Type | Required |
|---|---|---|
value | string | yes |
| returns | boolean |
Check if a processo jurídico number is valid, per Resolução CNJ nº 65/2008. Three things are checked: the NNNNNNN-DD.AAAA.J.TR.OOOO layout, the DD check digits (ISO 7064 MOD 97-10) and the J/TR pair.
JandTRmust name an órgão and a tribunal that exist.- The unidade de origem (
OOOO) is only checked as four digits.
import { isValidProcessoJuridico } from '@brazilian-utils/brazilian-utils';
isValidProcessoJuridico('00020802520125150049'); // true
isValidProcessoJuridico('0002080-25.2012.5.15.0049'); // true (CNJ mask)
isValidProcessoJuridico('0000100-68.2008.4.06.0000'); // true (TRF da 6ª Região)
isValidProcessoJuridico('0000100-23.2008.8.28.0000'); // false (no 28th Tribunal de Justiça)
isValidProcessoJuridico('ab00020802520125150049'); // false (letters are rejected)Source: Resolução CNJ nº 65/2008, art. 1º (layout, J and TR) and Anexo VIII ("CÁLCULO DO DÍGITO VERIFICADOR"); the TRF da 6ª Região (4.06) per Resolução CNJ nº 477/2022.
Try it with JavaScript isValidProcessoJuridico
Shared test cases (51) and the result in each library legalProcess.isValid
Format
- JavaScript library
- Python library25 cases fail
- Go library21 cases fail
- Ruby library25 cases fail
- Rust library22 cases fail
- .NET library22 cases fail
- Erlang library
Formats a court case number with the CNJ mask NNNNNNN-DD.AAAA.J.TR.OOOO.
- Every character that is not a digit is dropped first, and only the first 20 digits are kept. The mask is applied as far as the digits go, so a value being typed is masked progressively (
00020802gives0002080-2). options.padfirst left-pads the value with zeros to 20 digits.- A number is read only when it is a safe non-negative integer. A negative, fractional, non-finite or unsafe number returns an empty string (2.4.0 read the digits of any number, sign and decimal point dropped).
- An empty value, or one without digits, returns an empty string even with
pad. Until 2.4.0padreturned the whole zero mask.
Pending decision
The reference (JS) formats only the characters an incomplete value has. It returns an empty string for empty or invalid input. The other libraries return null. See the open decision in docs/findings.md.
| Parameter | Type | Required |
|---|---|---|
value | string | number | yes |
options | FormatProcessoJuridicoOptions | no |
options.pad | boolean | no |
| returns | string |
Format a processo jurídico number in the CNJ mask NNNNNNN-DD.AAAA.J.TR.OOOO.
- Options (
FormatProcessoJuridicoOptions):padleft-pads the value with zeros to 20 digits before masking (defaultfalse). An empty value, or one without digits, gives''even withpad.
import { formatProcessoJuridico } from '@brazilian-utils/brazilian-utils';
formatProcessoJuridico('00020802520125150049'); // '0002080-25.2012.5.15.0049'
formatProcessoJuridico('20802520125150049', { pad: true }); // '0002080-25.2012.5.15.0049'Source: Resolução CNJ nº 65/2008.
Code: brazilian-utils/javascriptTry it with JavaScript formatProcessoJuridico
Shared test cases (36) and the result in each library legalProcess.format
Parse
- JavaScript library
- Python library
- Go library
- Ruby library2 cases fail
- Rust library
- .NET library
- Erlang library
Removes court case number formatting and keeps only digits, capped at 20 digits.
- A number is read only when it is a safe non-negative integer. A negative, fractional, non-finite or unsafe number returns an empty string (2.4.0 read the digits of any number, sign and decimal point dropped).
| Parameter | Type | Required |
|---|---|---|
value | string | number | yes |
| returns | string |
Remove processo jurídico formatting, keep only digits, and cap the result to 20 digits.
import { parseProcessoJuridico } from '@brazilian-utils/brazilian-utils';
parseProcessoJuridico('0002080-25.2012.5.15.0049'); // '00020802520125150049'Try it with JavaScript parseProcessoJuridico
Shared test cases (19) and the result in each library legalProcess.parse
Generate
- JavaScript library
- Python library6 cases fail
- Go library
- Ruby library2 cases fail
- Rust library
- .NET library
- Erlang library
Generates a random valid court case number (20 digits, unformatted) in the NNNNNNNDDAAAAJTROOOO layout of Resolução CNJ nº 65/2008.
options.yearsets theAAAAfield: an integer from the current year to 9999 (default: the current year).options.courtsets the segmentJ: an integer from 1 to 9 (default: random).- The function picks
TRamong the tribunals of the chosen segment, so the pair always names a court that exists. The sequence number and the unidade de origem are random and the check digits are computed. - Returns
nullwhen the year or the segment is out of range or not an integer, or when the options are not an object.
| Parameter | Type | Required |
|---|---|---|
params | GenerateProcessoJuridicoParams | no |
params.year | number | no |
params.court | number | no |
| returns | string | null |
Generate a valid random processo jurídico number in the layout of Resolução CNJ nº 65/2008.
- Options (
GenerateProcessoJuridicoParams):yearsets theAAAAfield, an integer from the current year to 9999 (default: the current year);courtsets the órgãoJ, from 1 to 9 (default: random). TRis drawn among the tribunais of the chosen órgão, so the pair always names a court that exists.- Returns
nullwhenyearorcourtis out of range.
import { generateProcessoJuridico } from '@brazilian-utils/brazilian-utils';
generateProcessoJuridico(); // '89478645020266070326'
generateProcessoJuridico({ year: 2026, court: 5 }); // '98412562120265087260' (Justiça do Trabalho, TRT da 8ª Região)
generateProcessoJuridico({ year: 10000 }); // null (year out of range)
generateProcessoJuridico({ court: 10 }); // null (no such órgão)Source: Resolução CNJ nº 65/2008.
Code: brazilian-utils/javascriptTry it with JavaScript generateProcessoJuridico
Shared test cases (9) and the result in each library legalProcess.generate
Decode
Reads the fields of a processo jurídico number: the sequential number, the check digits, the year, the segment of the Judiciary (órgão J), the tribunal and the unit of origin.
- Returns
nullexactly whenlegalProcess.isValidreturnsfalse; the input rules are the same (the 20 digits, masked or not, as a string). - The result has
sequentialNumber(NNNNNNN),checkDigits(DD),year(AAAA, a number),segment,segmentCode(J,'1'to'9'),tribunalCode(TR, two digits) andoriginUnit(OOOO). Codes are strings that keep their leading zeros. segmentnames the órgãoJ:supreme-federal-court(1),national-council-of-justice(2),superior-court-of-justice(3),federal(4),labor(5),electoral(6),military(7),state(8) orstate-military(9).tribunalCodeis00for the processes of the STF, the CNJ, the STJ, the TST, the TSE and the STM,90for 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 result has no tribunal name.- The unit of origin is not checked: each tribunal codifies its own.
- Each call returns a new object.
| Parameter | Type | Required |
|---|---|---|
value | string | yes |
| returns | ProcessoJuridicoInfo | null |
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ãoJ:'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) andoriginUnit(OOOO). Codes are strings that keep their leading zeros. tribunalCodeis'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.
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.
Code: brazilian-utils/javascriptTry it with JavaScript getProcessoJuridicoInfo
Shared test cases (34) and the result in each library legalProcess.getInfo
Official sources
Last updated on
