Legal nature
Legal nature codes of the IBGE/CONCLA Natureza Jurídica 2021 table.
Validate
- JavaScript library
- Python library22 cases fail
- Go library13 cases fail
- Ruby library12 cases fail
- Rust library13 cases fail
- .NET library14 cases fail
- Erlang library
Checks whether a legal nature code exists in the IBGE/CONCLA Natureza Jurídica 2021 table.
- It accepts the 92 codes in force, plus the 8 codes that a past revision retired.
legalNature.gettells them apart. - Accepts the 4 digits, a safe non-negative integer or the
NNN-Nmask. The mask is accepted only after the third digit, with any run of separators (whitespace,.,-or/) between the third and the fourth digit:"206.2","206--2"and"206 - 2"are valid. Surrounding whitespace is ignored. - A separator anywhere else, or any other character, makes the value invalid:
"2-0-6-2","20.6.2","2062a". Until 2.4.0 the separators were stripped from anywhere in the string, so"-2-0-6-2"was valid. - A number is read only when it is a safe non-negative integer (
2062is valid). A negative, fractional, non-finite or unsafe number is invalid. Until 2.4.0 the function accepted only strings. - Any value that is not a string or a number returns
false.
| Parameter | Type | Required |
|---|---|---|
code | string | number | yes |
| returns | boolean |
Check if a legal nature code exists in the official list, the IBGE/CONCLA "Natureza Jurídica 2021" table. Accepts a string with the 4 digits or with the NNN-N mask, or a non-negative safe integer.
- A separator run (space,
.,-or/) is only read between the third and the fourth digit, so'2-0-6-2'is rejected. - The 92 codes in force are accepted, plus the 8 a past revision retired.
getLegalNaturetells them apart (legacy: true).
import { isValidLegalNature } from '@brazilian-utils/brazilian-utils';
isValidLegalNature('2062'); // true
isValidLegalNature(2062); // true
isValidLegalNature('206-2'); // true
isValidLegalNature('2208'); // true (retired by a past revision, still accepted)
isValidLegalNature('9999'); // false
isValidLegalNature('2-0-6-2'); // false (a separator only fits after the third digit)Source: CONCLA, Natureza Jurídica 2021 and its detailed structure PDF.
Code: brazilian-utils/javascriptTry it with JavaScript isValidLegalNature
Shared test cases (56) and the result in each library legalNature.isValid
Format
- JavaScript library
- Python library
- Go library
- Ruby library7 cases fail
- Rust library
- .NET library
- Erlang library
Formats a legal nature code as NNN-N. Use legalNature.isValid to check the code.
- The digits are read from the value and the mask is applied as far as they go:
"206"stays"206","2062"becomes"206-2".options.padfirst left-pads with zeros to 4 digits ("62"becomes"006-2"). - Digits after the 4th are ignored, and other characters are dropped. A number is treated as the string of its digits, so it is padded only with
pad. - A number is read only when it is a safe non-negative integer. A negative, fractional, non-finite or unsafe number gives an empty string (2.4.0 read the digits of any number, sign and decimal point dropped).
- Returns an empty string when there is nothing to format. Until 2.4.0 a value with no digits and
pad: truereturned"000-0".
| Parameter | Type | Required |
|---|---|---|
value | string | number | yes |
options | FormatLegalNatureOptions | no |
options.pad | boolean | no |
| returns | string |
Format a legal nature code. Use isValidLegalNature to check a code.
- Options (
FormatLegalNatureOptions):padfirst left-pads the value with zeros to the 4 digits of a complete code (defaultfalse). An empty value, or one without digits, gives''even withpad.
import { formatLegalNature } from '@brazilian-utils/brazilian-utils';
formatLegalNature('2062'); // 206-2
formatLegalNature(2062); // 206-2
formatLegalNature('206'); // 206 (masked as far as it goes)
formatLegalNature('62', { pad: true }); // 006-2 (padded to 4 digits first)Try it with JavaScript formatLegalNature
Shared test cases (19) and the result in each library legalNature.format
Parse
- JavaScript library
- Python library
- Go library
- Ruby library1 case fails
- Rust library
- .NET library
- Erlang library
Removes legal nature formatting and keeps only digits, capped at 4 digits.
- It does not left-pad anything. Returns an empty string when there is no digit at all (
nullandundefinedincluded). - A number is read only when it is a safe non-negative integer. A negative, fractional, non-finite or unsafe number gives 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 legal nature formatting, keep only digits, and cap the result to 4 digits.
import { parseLegalNature } from '@brazilian-utils/brazilian-utils';
parseLegalNature('206-2'); // '2062'Try it with JavaScript parseLegalNature
Shared test cases (7) and the result in each library legalNature.parse
Generate
Generates a random valid legal nature code (4 digits). It picks only among the 92 codes in force, never a retired one.
| Parameter | Type | Required |
|---|---|---|
| returns | string |
Generate a random valid legal nature code. Only the 92 codes in force are drawn, never a retired one.
import { generateLegalNature } from '@brazilian-utils/brazilian-utils';
generateLegalNature(); // '2062'Try it with JavaScript generateLegalNature
Shared test cases (1) and the result in each library legalNature.generate
Look up
- JavaScript library
- Python library
- Go library5 cases fail
- Ruby library4 cases fail
- Rust library
- .NET library5 cases fail
- Erlang library
Looks up a legal nature code in the IBGE/CONCLA Natureza Jurídica 2021 table. Returns null for an unknown code.
- Same input rules as
legalNature.isValid: the 4 digits, a safe non-negative integer or theNNN-Nmask, with any run of separators (whitespace,.,-or/) between the third and the fourth digit."206.2"finds 2062. Surrounding whitespace is ignored. - A separator anywhere else (
"2-0-6-2") or any other character ("2062a") returnsnull. Until 2.4.0 the separators were stripped from anywhere in the string. - A number is read only when it is a safe non-negative integer. A negative, fractional, non-finite or unsafe number returns
null. 2.4.0 stripped the sign and decimal point of a number too, so206.2found 2062. - No code starts with zero (the first digit is the category, 1 to 5), so nothing is padded: a number and the string of the same digits read the same.
- The entry has the code, its description and its CONCLA category (given by the first digit): 1 Administração Pública, 2 Entidades Empresariais, 3 Entidades sem Fins Lucrativos, 4 Pessoas Físicas, 5 Organizações Internacionais e Outras Instituições Extraterritoriais.
- A code that a past revision retired comes back with
legacy: trueand thecurrentCodeit corresponds to today, ornullwhen the revision that retired it published no successor (2100, 3050 and 3123). The 92 codes in force havelegacy: falseand nocurrentCode. - The retired codes and what each corresponds to today: 2076 to 2070, 2208 to 2275, 3042 to 3069, 3093 to 3999 and 5002 to 5010; 2100, 3050 and 3123 have no successor.
- It returns
nullexactly whenlegalNature.isValidreturnsfalse.
| Parameter | Type | Required |
|---|---|---|
value | string | number | yes |
| returns | LegalNature | null |
Look a legal nature code up in the official IBGE/CONCLA table. Returns null for an unknown code.
- The entry (
LegalNature) also carries the CONCLA category of the code, given by its first digit. - A code a past revision retired comes back with
legacy: trueand thecurrentCodeit corresponds to today, orcurrentCode: nullwhen there is no successor (2100,3050and3123). Codes in force havelegacy: falseand nocurrentCode.
| Retired code | Description | Corresponds to |
|---|---|---|
2076 | Sociedade Empresária em Nome Coletivo | 2070, the code the 2003.1 revision renumbered it to, same denomination |
2100 | Sociedade Mercantil de Capital e Indústria | none, marked "categoria extinta" by the 2003.1 x 2009 correspondence |
2208 | Entidade Binacional Itaipu | 2275 Empresa Binacional |
3042 | Organização Social | 3069 Fundação Privada; the 2014 revision later created 3301 Organização Social (OS), where an entity qualified as one is classified today |
3050 | Organização da Sociedade Civil de Interesse Público (Oscip) | none, an Oscip is classified by the form it takes (3999 or 3069) |
3093 | Unidade Executora (Programa Dinheiro Direto na Escola) | 3999 Associação Privada |
3123 | Partido Político | none, the 2014 revision split it into 3255, 3263 and 3271 |
5002 | Organização Internacional e Outras Instituições Extraterritoriais | 5010 Organização Internacional, the code it was opened into alongside 5029 and 5037 |
import { getLegalNature } from '@brazilian-utils/brazilian-utils';
getLegalNature('2062');
// {
// code: '2062',
// description: 'Sociedade Empresária Limitada',
// category: { code: '2', description: 'Entidades Empresariais' },
// legacy: false,
// }
getLegalNature('2208');
// {
// code: '2208',
// description: 'Entidade Binacional Itaipu',
// category: { code: '2', description: 'Entidades Empresariais' },
// legacy: true,
// currentCode: '2275',
// }
getLegalNature('3123')?.currentCode; // null (retired without a successor)
getLegalNature('206-2')?.code; // '2062'
getLegalNature('206.2')?.category.description; // 'Entidades Empresariais'
getLegalNature(206.2); // null (a number is only read when it is a non-negative safe integer: write the dotted form as a string)
getLegalNature('0000'); // nullSource: CONCLA, Natureza Jurídica 2021.
Code: brazilian-utils/javascriptTry it with JavaScript getLegalNature
Shared test cases (17) and the result in each library legalNature.get
List
- JavaScript library
- Python library1 case fails
- Go library
- Ruby library1 case fails
- Rust library
- .NET library1 case fails
- Erlang library
Returns the legal nature table as a map from code to description.
- By default, it returns only the 92 codes in force (
params.includeLegacyisfalse). The table is CONCLA's Natureza Jurídica 2021. params.includeLegacy: trueadds the 8 codes a past revision retired, 100 in all.legalNature.isValidandlegalNature.getaccept those codes either way.- It returns a fresh object on every call.
| Parameter | Type | Required |
|---|---|---|
params | GetLegalNaturesParams | no |
params.includeLegacy | boolean | no |
| returns | Record<string, string> |
Get the legal nature map keyed by code. Only the 92 codes in force are listed by default.
- Options (
GetLegalNaturesParams):includeLegacy(defaultfalse) adds the 8 retired codes.
import { getLegalNatures } from '@brazilian-utils/brazilian-utils';
const legalNatures = getLegalNatures();
legalNatures['2062']; // 'Sociedade Empresária Limitada'
Object.keys(legalNatures).length; // 92
legalNatures['2208']; // undefined (retired by a past revision)
getLegalNatures({ includeLegacy: true })['2208']; // 'Entidade Binacional Itaipu'Try it with JavaScript getLegalNatures
Shared test cases (2) and the result in each library legalNature.list
Get description
Returns the description of a legal nature code.
JavaScript does not have this function yet. Add it to the library.
Shared test cases (2) and the result in each library legalNature.getDescription
List by category
- JavaScript library
- Python library
- Go library1 case fails
- Ruby library2 cases fail
- Rust library
- .NET library2 cases fail
- Erlang library
Returns every legal nature of a CONCLA category (the first digit of the code), sorted by code.
- Categories: 1 Administração Pública, 2 Entidades Empresariais, 3 Entidades sem Fins Lucrativos, 4 Pessoas Físicas, 5 Organizações Internacionais e Outras Instituições Extraterritoriais.
categorymay be a string or a number:"2"and2return the same list. A prefix ("20"), a full code ("2062"), a padded value (" 2","02") and a value outside 1 to 5 are not categories.- Only the codes in force are listed by default (
options.includeLegacyisfalse). options.includeLegacy: trueadds the codes a past revision retired (2076, 2100 and 2208 in category 2, 3042, 3050, 3093 and 3123 in category 3, 5002 in category 5). They come back withlegacy: trueand thecurrentCode.- The result is a fresh array of fresh entries on every call.
- Returns an empty list for an unknown category or a value that is not a string or a number.
| Parameter | Type | Required |
|---|---|---|
category | string | number | yes |
options | GetLegalNaturesByCategoryOptions | no |
options.includeLegacy | boolean | no |
| returns | LegalNature[] |
Get every legal nature of a CONCLA category, the group given by the first digit of the code. The category is accepted as a string or as a number.
- Categories:
1Administração Pública,2Entidades Empresariais,3Entidades sem Fins Lucrativos,4Pessoas Físicas and5Organizações Internacionais e Outras Instituições Extraterritoriais. - Options (
GetLegalNaturesByCategoryOptions):includeLegacy(defaultfalse) adds the retired codes of the category. - The entries come back sorted by code. An unknown category returns
[].
import { getLegalNaturesByCategory } from '@brazilian-utils/brazilian-utils';
getLegalNaturesByCategory('4')[0];
// {
// code: '4014',
// description: 'Empresa Individual Imobiliária',
// category: { code: '4', description: 'Pessoas Físicas' },
// legacy: false,
// }
getLegalNaturesByCategory(4).length; // 6
getLegalNaturesByCategory('2').length; // 30
getLegalNaturesByCategory('2', { includeLegacy: true }).length; // 33
getLegalNaturesByCategory('9'); // []Try it with JavaScript getLegalNaturesByCategory
Shared test cases (17) and the result in each library legalNature.listByCategory
Official sources
- concla.ibge.gov.br/estrutura/natjur-estrutura/…/natureza-juridica-2021
- concla.ibge.gov.br/images/concla/…/CONCLA-TNJ2021-EstruturaDetalhada.pdf
- concla.ibge.gov.br/classificacoes/correspondencias/…/natureza-juridica.html
- concla.ibge.gov.br/images/concla/…/correspTNJ2003(1)-2009.xls
- concla.ibge.gov.br/images/concla/…/correspTNJ1995-2002-2003.xls
See also CNPJ
Last updated on
