{
  "$schema": "../cases.schema.json",
  "format": 1,
  "domain": "legalNature",
  "title": {
    "en": "Legal nature",
    "pt-BR": "Natureza jurídica"
  },
  "functions": [
    {
      "id": "legalNature.format",
      "level": "extended",
      "summary": "Formats a Brazilian legal nature code.",
      "description": "Formats a legal nature code as `NNN-N`. Use `legalNature.isValid` to check the code.\n\n- 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.pad` first left-pads with zeros to 4 digits (`\"62\"` becomes `\"006-2\"`).\n- 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`.\n- 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).\n- Returns an empty string when there is nothing to format. Until 2.4.0 a value with no digits and `pad: true` returned `\"000-0\"`.",
      "params": [
        {
          "name": "value",
          "type": "string | number"
        },
        {
          "name": "options",
          "type": "FormatLegalNatureOptions",
          "optional": true
        }
      ],
      "returns": "string",
      "cases": [
        {
          "id": "legalNature.format#[\"2062\"]",
          "args": [
            "2062"
          ],
          "expect": {
            "returns": "206-2"
          }
        },
        {
          "id": "legalNature.format#already-formatted",
          "args": [
            "206-2"
          ],
          "expect": {
            "returns": "206-2"
          }
        },
        {
          "id": "legalNature.format#partial",
          "args": [
            "206"
          ],
          "expect": {
            "returns": "206"
          }
        },
        {
          "id": "legalNature.format#empty",
          "args": [
            ""
          ],
          "expect": {
            "returns": ""
          }
        },
        {
          "id": "legalNature.format#[\"2\"]",
          "args": [
            "2"
          ],
          "expect": {
            "returns": "2"
          },
          "note": "JavaScript's own test: should format legal nature values"
        },
        {
          "id": "legalNature.format#[\"20\"]",
          "args": [
            "20"
          ],
          "expect": {
            "returns": "20"
          },
          "note": "JavaScript's own test: should format legal nature values"
        },
        {
          "id": "legalNature.format#[2062]",
          "args": [
            2062
          ],
          "expect": {
            "returns": "206-2"
          },
          "note": "JavaScript's own test: should format a number and read only the digits of a masked value, like formatCpf"
        },
        {
          "id": "legalNature.format#[\"abc2062\"]",
          "args": [
            "abc2062"
          ],
          "expect": {
            "returns": "206-2"
          },
          "note": "JavaScript's own test: should format a number and read only the digits of a masked value, like formatCpf"
        },
        {
          "id": "legalNature.format#[\"62\",{\"pad\":true}]",
          "args": [
            "62",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "006-2"
          },
          "note": "JavaScript's own test: should left pad with zeros to 4 digits when pad is true"
        },
        {
          "id": "legalNature.format#[62,{\"pad\":true}]",
          "args": [
            62,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "006-2"
          },
          "note": "JavaScript's own test: should left pad with zeros to 4 digits when pad is true"
        },
        {
          "id": "legalNature.format#[\"2062\",{\"pad\":true}]",
          "args": [
            "2062",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "206-2"
          },
          "note": "JavaScript's own test: should left pad with zeros to 4 digits when pad is true"
        },
        {
          "id": "legalNature.format#[\"62\",{\"pad\":false}]",
          "args": [
            "62",
            {
              "pad": false
            }
          ],
          "expect": {
            "returns": "62"
          },
          "note": "JavaScript's own test: should left pad with zeros to 4 digits when pad is true"
        },
        {
          "id": "legalNature.format#[206.2]",
          "args": [
            206.2
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: should return an empty string when it is a negative, fractional or unsafe number (#593 number rule)"
        },
        {
          "id": "legalNature.format#[-1]",
          "args": [
            -1
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: should return an empty string when it is a negative, fractional or unsafe number (#593 number rule)"
        },
        {
          "id": "legalNature.format#[1.5]",
          "args": [
            1.5
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: should return an empty string when it is a negative, fractional or unsafe number (#593 number rule)"
        },
        {
          "id": "legalNature.format#[9007199254740992]",
          "args": [
            9007199254740992
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: should return an empty string when it is a negative, fractional or unsafe number (#593 number rule)"
        },
        {
          "id": "legalNature.format#[206.2,{\"pad\":true}]",
          "args": [
            206.2,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: should return an empty string when it is a negative, fractional or unsafe number (#593 number rule)"
        },
        {
          "id": "legalNature.format#[\"\",{\"pad\":true}]",
          "args": [
            "",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": ""
          },
          "note": "changed in 2.5.0 (#615): a value with no digits gives an empty string even with pad (2.4.0: \"000-0\")"
        },
        {
          "id": "legalNature.format#[\"abc\",{\"pad\":true}]",
          "args": [
            "abc",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": ""
          },
          "note": "changed in 2.5.0 (#615): a value with no digits gives an empty string even with pad"
        }
      ]
    },
    {
      "id": "legalNature.generate",
      "level": "extended",
      "summary": "Generates a random valid Brazilian legal nature code.",
      "description": "Generates a random valid legal nature code (4 digits). It picks only among the 92 codes in force, never a retired one.",
      "params": [],
      "returns": "string",
      "cases": [
        {
          "id": "legalNature.generate#generated-is-valid",
          "args": [],
          "expect": {
            "satisfies": "legalNature.isValid"
          },
          "repeat": 5,
          "note": "every generated value must pass the lib's own validator"
        }
      ]
    },
    {
      "id": "legalNature.get",
      "level": "extended",
      "summary": "Looks up a Brazilian legal nature code.",
      "description": "Looks up a legal nature code in the IBGE/CONCLA Natureza Jurídica 2021 table. Returns `null` for an unknown code.\n\n- Same input rules as `legalNature.isValid`: the 4 digits, a safe non-negative integer or the `NNN-N` mask, with any run of separators (whitespace, `.`, `-` or `/`) between the third and the fourth digit. `\"206.2\"` finds 2062. Surrounding whitespace is ignored.\n- A separator anywhere else (`\"2-0-6-2\"`) or any other character (`\"2062a\"`) returns `null`. Until 2.4.0 the separators were stripped from anywhere in the string.\n- 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, so `206.2` found 2062.\n- 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.\n- 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.\n- A code that a past revision retired comes back with `legacy: true` and the `currentCode` it corresponds to today, or `null` when the revision that retired it published no successor (2100, 3050 and 3123). The 92 codes in force have `legacy: false` and no `currentCode`.\n- 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.\n- It returns `null` exactly when `legalNature.isValid` returns `false`.",
      "params": [
        {
          "name": "value",
          "type": "string | number"
        }
      ],
      "returns": "LegalNature?",
      "cases": [
        {
          "id": "legalNature.get#[\"2062\"]",
          "args": [
            "2062"
          ],
          "expect": {
            "returns": {
              "code": "2062",
              "description": "Sociedade Empresária Limitada",
              "category": {
                "code": "2",
                "description": "Entidades Empresariais"
              },
              "legacy": false
            }
          }
        },
        {
          "id": "legalNature.get#masked",
          "args": [
            "206-2"
          ],
          "expect": {
            "returns": {
              "code": "2062",
              "description": "Sociedade Empresária Limitada",
              "category": {
                "code": "2",
                "description": "Entidades Empresariais"
              },
              "legacy": false
            }
          }
        },
        {
          "id": "legalNature.get#legacy-code",
          "args": [
            "2208"
          ],
          "expect": {
            "returns": {
              "code": "2208",
              "description": "Entidade Binacional Itaipu",
              "category": {
                "code": "2",
                "description": "Entidades Empresariais"
              },
              "legacy": true,
              "currentCode": "2275"
            }
          }
        },
        {
          "id": "legalNature.get#[\"0000\"]",
          "args": [
            "0000"
          ],
          "expect": {
            "returns": null
          }
        },
        {
          "id": "legalNature.get#too-short",
          "args": [
            "206"
          ],
          "expect": {
            "returns": null
          }
        },
        {
          "id": "legalNature.get#empty",
          "args": [
            ""
          ],
          "expect": {
            "returns": null
          }
        },
        {
          "id": "legalNature.get#[\"2062a\"]",
          "args": [
            "2062a"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should reject a code with letters attached, like isValidLegalNature does"
        },
        {
          "id": "legalNature.get#[\"a2062\"]",
          "args": [
            "a2062"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should reject a code with letters attached, like isValidLegalNature does"
        },
        {
          "id": "legalNature.get#[2062]",
          "args": [
            2062
          ],
          "expect": {
            "returns": {
              "code": "2062",
              "description": "Sociedade Empresária Limitada",
              "category": {
                "code": "2",
                "description": "Entidades Empresariais"
              },
              "legacy": false
            }
          },
          "note": "JavaScript's own test: should return the legal nature entry for a known code as a number"
        },
        {
          "id": "legalNature.get#[206.2]",
          "args": [
            206.2
          ],
          "expect": {
            "returns": null
          },
          "note": "changed in 2.5.0 (#593): 206.2 is not a non-negative safe integer, so it is not read as a code; 2.4.0 stripped the decimal point like a mask character and found 2062. JavaScript's own test: should return null for a negative or fractional number"
        },
        {
          "id": "legalNature.get#[\"2076\"]",
          "args": [
            "2076"
          ],
          "expect": {
            "returns": {
              "code": "2076",
              "description": "Sociedade Empresária em Nome Coletivo",
              "category": {
                "code": "2",
                "description": "Entidades Empresariais"
              },
              "legacy": true,
              "currentCode": "2070"
            }
          },
          "note": "JavaScript's own test: should tag a retired code as legacy, with the code it corresponds to today"
        },
        {
          "id": "legalNature.get#[-2062]",
          "args": [
            -2062
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a negative or fractional number"
        },
        {
          "id": "legalNature.get#[\"206.2\"]",
          "args": [
            "206.2"
          ],
          "expect": {
            "returns": {
              "code": "2062",
              "description": "Sociedade Empresária Limitada",
              "category": {
                "code": "2",
                "description": "Entidades Empresariais"
              },
              "legacy": false
            }
          },
          "note": "JavaScript's own test: should strip the mask of a string, the dot included"
        },
        {
          "id": "legalNature.get#[\"206--2\"]",
          "args": [
            "206--2"
          ],
          "expect": {
            "returns": {
              "code": "2062",
              "description": "Sociedade Empresária Limitada",
              "category": {
                "code": "2",
                "description": "Entidades Empresariais"
              },
              "legacy": false
            }
          },
          "note": "any run of separators is accepted after the third digit"
        },
        {
          "id": "legalNature.get#[\"2-0-6-2\"]",
          "args": [
            "2-0-6-2"
          ],
          "expect": {
            "returns": null
          },
          "note": "changed in 2.5.0 (#615): a separator is accepted only after the third digit; JavaScript docs example"
        },
        {
          "id": "legalNature.get#[\"2062-\"]",
          "args": [
            "2062-"
          ],
          "expect": {
            "returns": null
          },
          "note": "a separator is accepted only after the third digit"
        },
        {
          "id": "legalNature.get#[\"3123\"]",
          "args": [
            "3123"
          ],
          "expect": {
            "returns": {
              "code": "3123",
              "description": "Partido Político",
              "category": {
                "code": "3",
                "description": "Entidades sem Fins Lucrativos"
              },
              "legacy": true,
              "currentCode": null
            }
          },
          "note": "JavaScript docs example: retired without a successor"
        }
      ]
    },
    {
      "id": "legalNature.getDescription",
      "level": "core",
      "summary": "Returns the description of a legal nature code.",
      "params": [
        {
          "name": "code",
          "type": "string"
        }
      ],
      "returns": "string?",
      "cases": [
        {
          "id": "legalNature.getDescription#[\"2240\"]",
          "args": [
            "2240"
          ],
          "expect": {
            "returns": "Sociedade Simples Limitada"
          },
          "note": "consensus of 4 libs (go, python, ruby, rust)"
        },
        {
          "id": "legalNature.getDescription#[\"224-0\"]",
          "args": [
            "224-0"
          ],
          "expect": {
            "returns": "Sociedade Simples Limitada"
          },
          "note": "consensus of 4 libs (go, python, ruby, rust)"
        }
      ]
    },
    {
      "id": "legalNature.isValid",
      "level": "core",
      "summary": "Checks whether a Brazilian legal nature code exists.",
      "description": "Checks whether a legal nature code exists in the IBGE/CONCLA Natureza Jurídica 2021 table.\n\n- It accepts the 92 codes in force, plus the 8 codes that a past revision retired. `legalNature.get` tells them apart.\n- Accepts the 4 digits, a safe non-negative integer or the `NNN-N` mask. 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.\n- 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.\n- A number is read only when it is a safe non-negative integer (`2062` is valid). A negative, fractional, non-finite or unsafe number is invalid. Until 2.4.0 the function accepted only strings.\n- Any value that is not a string or a number returns `false`.",
      "params": [
        {
          "name": "code",
          "type": "string | number"
        }
      ],
      "returns": "boolean",
      "cases": [
        {
          "id": "legalNature.isValid#[\"3329\"]",
          "args": [
            "3329"
          ],
          "expect": {
            "returns": false
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "legalNature.isValid#[\"0000\"]",
          "args": [
            "0000"
          ],
          "expect": {
            "returns": false
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "legalNature.isValid#[\"2240\"]",
          "args": [
            "2240"
          ],
          "expect": {
            "returns": true
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "legalNature.isValid#[\"2241\"]",
          "args": [
            "2241"
          ],
          "expect": {
            "returns": false
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "legalNature.isValid#[\"3311\"]",
          "args": [
            "3311"
          ],
          "expect": {
            "returns": false
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "legalNature.isValid#[\"224-0\"]",
          "args": [
            "224-0"
          ],
          "expect": {
            "returns": true
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "legalNature.isValid#[\"\"]",
          "args": [
            ""
          ],
          "expect": {
            "returns": false
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "legalNature.isValid#[\"   \"]",
          "args": [
            "   "
          ],
          "expect": {
            "returns": false
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "legalNature.isValid#[\"abc\"]",
          "args": [
            "abc"
          ],
          "expect": {
            "returns": false
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "legalNature.isValid#[\"2062\"]",
          "args": [
            "2062"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate legal nature codes"
        },
        {
          "id": "legalNature.isValid#[\"206-2\"]",
          "args": [
            "206-2"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate legal nature codes"
        },
        {
          "id": "legalNature.isValid#[\"9999\"]",
          "args": [
            "9999"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should validate legal nature codes"
        },
        {
          "id": "legalNature.isValid#[\"5010\"]",
          "args": [
            "5010"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate codes introduced by the 2021 CONCLA table"
        },
        {
          "id": "legalNature.isValid#[\"1244\"]",
          "args": [
            "1244"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate codes introduced by the 2021 CONCLA table"
        },
        {
          "id": "legalNature.isValid#[\"1252\"]",
          "args": [
            "1252"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate codes introduced by the 2021 CONCLA table"
        },
        {
          "id": "legalNature.isValid#[\"2348\"]",
          "args": [
            "2348"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate codes introduced by the 2021 CONCLA table"
        },
        {
          "id": "legalNature.isValid#[\"2356\"]",
          "args": [
            "2356"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate codes introduced by the 2021 CONCLA table"
        },
        {
          "id": "legalNature.isValid#[\"3301\"]",
          "args": [
            "3301"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate codes introduced by the 2021 CONCLA table"
        },
        {
          "id": "legalNature.isValid#[\"4090\"]",
          "args": [
            "4090"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate codes introduced by the 2021 CONCLA table"
        },
        {
          "id": "legalNature.isValid#[\"4111\"]",
          "args": [
            "4111"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate codes introduced by the 2021 CONCLA table"
        },
        {
          "id": "legalNature.isValid#[\"4120\"]",
          "args": [
            "4120"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should validate codes introduced by the 2021 CONCLA table"
        },
        {
          "id": "legalNature.isValid#[\"5002\"]",
          "args": [
            "5002"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should keep validating codes extinguished by CONCLA"
        },
        {
          "id": "legalNature.isValid#[\"3123\"]",
          "args": [
            "3123"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should keep validating codes extinguished by CONCLA"
        },
        {
          "id": "legalNature.isValid#[\"2076\"]",
          "args": [
            "2076"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should keep validating codes extinguished by CONCLA"
        },
        {
          "id": "legalNature.isValid#[\"206\"]",
          "args": [
            "206"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject codes with a length different from 4"
        },
        {
          "id": "legalNature.isValid#[\"20620\"]",
          "args": [
            "20620"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject codes with a length different from 4"
        },
        {
          "id": "legalNature.isValid#[\"2062a\"]",
          "args": [
            "2062a"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject any character other than digits and the mask"
        },
        {
          "id": "legalNature.isValid#[\"a2062\"]",
          "args": [
            "a2062"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject any character other than digits and the mask"
        },
        {
          "id": "legalNature.isValid#[\"20/62\"]",
          "args": [
            "20/62"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject any character other than digits and the mask"
        },
        {
          "id": "legalNature.isValid#[\" 206-2 \"]",
          "args": [
            " 206-2 "
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should reject any character other than digits and the mask"
        },
        {
          "id": "legalNature.isValid#[\"206.2\"]",
          "args": [
            "206.2"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should reject any character other than digits and the mask"
        },
        {
          "id": "legalNature.isValid#[\"constructor\"]",
          "args": [
            "constructor"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for names inherited from Object.prototype"
        },
        {
          "id": "legalNature.isValid#[\"toString\"]",
          "args": [
            "toString"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for names inherited from Object.prototype"
        },
        {
          "id": "legalNature.isValid#[\"__proto__\"]",
          "args": [
            "__proto__"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false for names inherited from Object.prototype"
        },
        {
          "id": "legalNature.isValid#[2062]",
          "args": [
            2062
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should accept a number, like getLegalNature does (changed in 2.5.0, #615: numbers are accepted)"
        },
        {
          "id": "legalNature.isValid#[2208]",
          "args": [
            2208
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should accept a number, like getLegalNature does"
        },
        {
          "id": "legalNature.isValid#[9999]",
          "args": [
            9999
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should accept a number, like getLegalNature does"
        },
        {
          "id": "legalNature.isValid#[206]",
          "args": [
            206
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should accept a number, like getLegalNature does"
        },
        {
          "id": "legalNature.isValid#[20620]",
          "args": [
            20620
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should accept a number, like getLegalNature does"
        },
        {
          "id": "legalNature.isValid#[-2062]",
          "args": [
            -2062
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject a number that is not a non-negative safe integer"
        },
        {
          "id": "legalNature.isValid#[206.2]",
          "args": [
            206.2
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject a number that is not a non-negative safe integer"
        },
        {
          "id": "legalNature.isValid#[1152921504606847000]",
          "args": [
            1152921504606847000
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject a number that is not a non-negative safe integer"
        },
        {
          "id": "legalNature.isValid#[\"206--2\"]",
          "args": [
            "206--2"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should accept any run of separators after the third digit"
        },
        {
          "id": "legalNature.isValid#[\"206 - 2\"]",
          "args": [
            "206 - 2"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should accept any run of separators after the third digit"
        },
        {
          "id": "legalNature.isValid#[\"206./ 2\"]",
          "args": [
            "206./ 2"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should accept any run of separators after the third digit"
        },
        {
          "id": "legalNature.isValid#[\"206 2\"]",
          "args": [
            "206 2"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should reject any character other than digits and the mask"
        },
        {
          "id": "legalNature.isValid#[\"206/2\"]",
          "args": [
            "206/2"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should reject any character other than digits and the mask"
        },
        {
          "id": "legalNature.isValid#[\"20_62\"]",
          "args": [
            "20_62"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject any character other than digits and the mask"
        },
        {
          "id": "legalNature.isValid#[\"-2062\"]",
          "args": [
            "-2062"
          ],
          "expect": {
            "returns": false
          },
          "note": "changed in 2.5.0 (#615): the mask is accepted only after the third digit. JavaScript's own test: should reject a separator anywhere but after the third digit"
        },
        {
          "id": "legalNature.isValid#[\"2062-\"]",
          "args": [
            "2062-"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject a separator anywhere but after the third digit"
        },
        {
          "id": "legalNature.isValid#[\"-2-0-6-2\"]",
          "args": [
            "-2-0-6-2"
          ],
          "expect": {
            "returns": false
          },
          "note": "changed in 2.5.0 (#615): was true in 2.4.0. JavaScript's own test: should reject a separator anywhere but after the third digit"
        },
        {
          "id": "legalNature.isValid#[\"2-0-6-2\"]",
          "args": [
            "2-0-6-2"
          ],
          "expect": {
            "returns": false
          },
          "note": "changed in 2.5.0 (#615): was true in 2.4.0. JavaScript docs example"
        },
        {
          "id": "legalNature.isValid#[\"20.6.2\"]",
          "args": [
            "20.6.2"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject a separator anywhere but after the third digit"
        },
        {
          "id": "legalNature.isValid#[\"20 62\"]",
          "args": [
            "20 62"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject a separator anywhere but after the third digit"
        },
        {
          "id": "legalNature.isValid#[\"2-062\"]",
          "args": [
            "2-062"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should reject a separator anywhere but after the third digit"
        },
        {
          "id": "legalNature.isValid#[\"2208\"]",
          "args": [
            "2208"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript docs example: retired by a past revision, still accepted"
        }
      ]
    },
    {
      "id": "legalNature.list",
      "level": "core",
      "summary": "Returns every Brazilian legal nature that CONCLA publishes.",
      "description": "Returns the legal nature table as a map from code to description.\n\n- By default, it returns only the 92 codes in force (`params.includeLegacy` is `false`). The table is CONCLA's Natureza Jurídica 2021.\n- `params.includeLegacy: true` adds the 8 codes a past revision retired, 100 in all. `legalNature.isValid` and `legalNature.get` accept those codes either way.\n- It returns a fresh object on every call.",
      "params": [
        {
          "name": "params",
          "type": "GetLegalNaturesParams",
          "optional": true
        }
      ],
      "returns": "object",
      "cases": [
        {
          "id": "legalNature.list#in-force-codes",
          "args": [],
          "expect": {
            "returns": {
              "1015": "Órgão Público do Poder Executivo Federal",
              "1023": "Órgão Público do Poder Executivo Estadual ou do Distrito Federal",
              "1031": "Órgão Público do Poder Executivo Municipal",
              "1040": "Órgão Público do Poder Legislativo Federal",
              "1058": "Órgão Público do Poder Legislativo Estadual ou do Distrito Federal",
              "1066": "Órgão Público do Poder Legislativo Municipal",
              "1074": "Órgão Público do Poder Judiciário Federal",
              "1082": "Órgão Público do Poder Judiciário Estadual",
              "1104": "Autarquia Federal",
              "1112": "Autarquia Estadual ou do Distrito Federal",
              "1120": "Autarquia Municipal",
              "1139": "Fundação Pública de Direito Público Federal",
              "1147": "Fundação Pública de Direito Público Estadual ou do Distrito Federal",
              "1155": "Fundação Pública de Direito Público Municipal",
              "1163": "Órgão Público Autônomo Federal",
              "1171": "Órgão Público Autônomo Estadual ou do Distrito Federal",
              "1180": "Órgão Público Autônomo Municipal",
              "1198": "Comissão Polinacional",
              "1210": "Consórcio Público de Direito Público (Associação Pública)",
              "1228": "Consórcio Público de Direito Privado",
              "1236": "Estado ou Distrito Federal",
              "1244": "Município",
              "1252": "Fundação Pública de Direito Privado Federal",
              "1260": "Fundação Pública de Direito Privado Estadual ou do Distrito Federal",
              "1279": "Fundação Pública de Direito Privado Municipal",
              "1287": "Fundo Público da Administração Indireta Federal",
              "1295": "Fundo Público da Administração Indireta Estadual ou do Distrito Federal",
              "1309": "Fundo Público da Administração Indireta Municipal",
              "1317": "Fundo Público da Administração Direta Federal",
              "1325": "Fundo Público da Administração Direta Estadual ou do Distrito Federal",
              "1333": "Fundo Público da Administração Direta Municipal",
              "1341": "União",
              "2011": "Empresa Pública",
              "2038": "Sociedade de Economia Mista",
              "2046": "Sociedade Anônima Aberta",
              "2054": "Sociedade Anônima Fechada",
              "2062": "Sociedade Empresária Limitada",
              "2070": "Sociedade Empresária em Nome Coletivo",
              "2089": "Sociedade Empresária em Comandita Simples",
              "2097": "Sociedade Empresária em Comandita por Ações",
              "2127": "Sociedade em Conta de Participação",
              "2135": "Empresário (Individual)",
              "2143": "Cooperativa",
              "2151": "Consórcio de Sociedades",
              "2160": "Grupo de Sociedades",
              "2178": "Estabelecimento, no Brasil, de Sociedade Estrangeira",
              "2194": "Estabelecimento, no Brasil, de Empresa Binacional Argentino-Brasileira",
              "2216": "Empresa Domiciliada no Exterior",
              "2224": "Clube/Fundo de Investimento",
              "2232": "Sociedade Simples Pura",
              "2240": "Sociedade Simples Limitada",
              "2259": "Sociedade Simples em Nome Coletivo",
              "2267": "Sociedade Simples em Comandita Simples",
              "2275": "Empresa Binacional",
              "2283": "Consórcio de Empregadores",
              "2291": "Consórcio Simples",
              "2305": "Empresa Individual de Responsabilidade Limitada (de Natureza Empresária)",
              "2313": "Empresa Individual de Responsabilidade Limitada (de Natureza Simples)",
              "2321": "Sociedade Unipessoal de Advogados",
              "2330": "Cooperativas de Consumo",
              "2348": "Empresa Simples de Inovação - Inova Simples",
              "2356": "Investidor Não Residente",
              "3034": "Serviço Notarial e Registral (Cartório)",
              "3069": "Fundação Privada",
              "3077": "Serviço Social Autônomo",
              "3085": "Condomínio Edilício",
              "3107": "Comissão de Conciliação Prévia",
              "3115": "Entidade de Mediação e Arbitragem",
              "3131": "Entidade Sindical",
              "3204": "Estabelecimento, no Brasil, de Fundação ou Associação Estrangeiras",
              "3212": "Fundação ou Associação Domiciliada no Exterior",
              "3220": "Organização Religiosa",
              "3239": "Comunidade Indígena",
              "3247": "Fundo Privado",
              "3255": "Órgão de Direção Nacional de Partido Político",
              "3263": "Órgão de Direção Regional de Partido Político",
              "3271": "Órgão de Direção Local de Partido Político",
              "3280": "Comitê Financeiro de Partido Político",
              "3298": "Frente Plebiscitária ou Referendária",
              "3301": "Organização Social (OS)",
              "3310": "Demais Condomínios",
              "3328": "Plano de Benefícios de Previdência Complementar Fechada",
              "3999": "Associação Privada",
              "4014": "Empresa Individual Imobiliária",
              "4022": "Segurado Especial",
              "4081": "Contribuinte individual",
              "4090": "Candidato a Cargo Político Eletivo",
              "4111": "Leiloeiro",
              "4120": "Produtor Rural (Pessoa Física)",
              "5010": "Organização Internacional",
              "5029": "Representação Diplomática Estrangeira",
              "5037": "Outras Instituições Extraterritoriais"
            }
          },
          "note": "the 92 codes of the CONCLA Tabela de Natureza Jurídica 2021 in force, code -> description, as held by the reference (its tests assert 92 entries and that retired codes such as 2208 are excluded)"
        },
        {
          "id": "legalNature.list#include-legacy",
          "args": [
            {
              "includeLegacy": true
            }
          ],
          "expect": {
            "returns": {
              "1015": "Órgão Público do Poder Executivo Federal",
              "1023": "Órgão Público do Poder Executivo Estadual ou do Distrito Federal",
              "1031": "Órgão Público do Poder Executivo Municipal",
              "1040": "Órgão Público do Poder Legislativo Federal",
              "1058": "Órgão Público do Poder Legislativo Estadual ou do Distrito Federal",
              "1066": "Órgão Público do Poder Legislativo Municipal",
              "1074": "Órgão Público do Poder Judiciário Federal",
              "1082": "Órgão Público do Poder Judiciário Estadual",
              "1104": "Autarquia Federal",
              "1112": "Autarquia Estadual ou do Distrito Federal",
              "1120": "Autarquia Municipal",
              "1139": "Fundação Pública de Direito Público Federal",
              "1147": "Fundação Pública de Direito Público Estadual ou do Distrito Federal",
              "1155": "Fundação Pública de Direito Público Municipal",
              "1163": "Órgão Público Autônomo Federal",
              "1171": "Órgão Público Autônomo Estadual ou do Distrito Federal",
              "1180": "Órgão Público Autônomo Municipal",
              "1198": "Comissão Polinacional",
              "1210": "Consórcio Público de Direito Público (Associação Pública)",
              "1228": "Consórcio Público de Direito Privado",
              "1236": "Estado ou Distrito Federal",
              "1244": "Município",
              "1252": "Fundação Pública de Direito Privado Federal",
              "1260": "Fundação Pública de Direito Privado Estadual ou do Distrito Federal",
              "1279": "Fundação Pública de Direito Privado Municipal",
              "1287": "Fundo Público da Administração Indireta Federal",
              "1295": "Fundo Público da Administração Indireta Estadual ou do Distrito Federal",
              "1309": "Fundo Público da Administração Indireta Municipal",
              "1317": "Fundo Público da Administração Direta Federal",
              "1325": "Fundo Público da Administração Direta Estadual ou do Distrito Federal",
              "1333": "Fundo Público da Administração Direta Municipal",
              "1341": "União",
              "2011": "Empresa Pública",
              "2038": "Sociedade de Economia Mista",
              "2046": "Sociedade Anônima Aberta",
              "2054": "Sociedade Anônima Fechada",
              "2062": "Sociedade Empresária Limitada",
              "2070": "Sociedade Empresária em Nome Coletivo",
              "2076": "Sociedade Empresária em Nome Coletivo",
              "2089": "Sociedade Empresária em Comandita Simples",
              "2097": "Sociedade Empresária em Comandita por Ações",
              "2100": "Sociedade Mercantil de Capital e Indústria (extinta pelo NCC/2002)",
              "2127": "Sociedade em Conta de Participação",
              "2135": "Empresário (Individual)",
              "2143": "Cooperativa",
              "2151": "Consórcio de Sociedades",
              "2160": "Grupo de Sociedades",
              "2178": "Estabelecimento, no Brasil, de Sociedade Estrangeira",
              "2194": "Estabelecimento, no Brasil, de Empresa Binacional Argentino-Brasileira",
              "2208": "Entidade Binacional Itaipu",
              "2216": "Empresa Domiciliada no Exterior",
              "2224": "Clube/Fundo de Investimento",
              "2232": "Sociedade Simples Pura",
              "2240": "Sociedade Simples Limitada",
              "2259": "Sociedade Simples em Nome Coletivo",
              "2267": "Sociedade Simples em Comandita Simples",
              "2275": "Empresa Binacional",
              "2283": "Consórcio de Empregadores",
              "2291": "Consórcio Simples",
              "2305": "Empresa Individual de Responsabilidade Limitada (de Natureza Empresária)",
              "2313": "Empresa Individual de Responsabilidade Limitada (de Natureza Simples)",
              "2321": "Sociedade Unipessoal de Advogados",
              "2330": "Cooperativas de Consumo",
              "2348": "Empresa Simples de Inovação - Inova Simples",
              "2356": "Investidor Não Residente",
              "3034": "Serviço Notarial e Registral (Cartório)",
              "3042": "Organização Social",
              "3050": "Organização da Sociedade Civil de Interesse Público (Oscip)",
              "3069": "Fundação Privada",
              "3077": "Serviço Social Autônomo",
              "3085": "Condomínio Edilício",
              "3093": "Unidade Executora (Programa Dinheiro Direto na Escola)",
              "3107": "Comissão de Conciliação Prévia",
              "3115": "Entidade de Mediação e Arbitragem",
              "3123": "Partido Político",
              "3131": "Entidade Sindical",
              "3204": "Estabelecimento, no Brasil, de Fundação ou Associação Estrangeiras",
              "3212": "Fundação ou Associação Domiciliada no Exterior",
              "3220": "Organização Religiosa",
              "3239": "Comunidade Indígena",
              "3247": "Fundo Privado",
              "3255": "Órgão de Direção Nacional de Partido Político",
              "3263": "Órgão de Direção Regional de Partido Político",
              "3271": "Órgão de Direção Local de Partido Político",
              "3280": "Comitê Financeiro de Partido Político",
              "3298": "Frente Plebiscitária ou Referendária",
              "3301": "Organização Social (OS)",
              "3310": "Demais Condomínios",
              "3328": "Plano de Benefícios de Previdência Complementar Fechada",
              "3999": "Associação Privada",
              "4014": "Empresa Individual Imobiliária",
              "4022": "Segurado Especial",
              "4081": "Contribuinte individual",
              "4090": "Candidato a Cargo Político Eletivo",
              "4111": "Leiloeiro",
              "4120": "Produtor Rural (Pessoa Física)",
              "5002": "Organização Internacional e Outras Instituições Extraterritoriais",
              "5010": "Organização Internacional",
              "5029": "Representação Diplomática Estrangeira",
              "5037": "Outras Instituições Extraterritoriais"
            }
          },
          "note": "JavaScript docs example: includeLegacy adds the 8 retired codes (100 entries)"
        }
      ]
    },
    {
      "id": "legalNature.listByCategory",
      "level": "extended",
      "summary": "Gets every Brazilian legal nature of a CONCLA category.",
      "description": "Returns every legal nature of a CONCLA category (the first digit of the code), sorted by code.\n\n- 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.\n- `category` may be a string or a number: `\"2\"` and `2` return 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.\n- Only the codes in force are listed by default (`options.includeLegacy` is `false`).\n- `options.includeLegacy: true` adds 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 with `legacy: true` and the `currentCode`.\n- The result is a fresh array of fresh entries on every call.\n- Returns an empty list for an unknown category or a value that is not a string or a number.",
      "params": [
        {
          "name": "category",
          "type": "string | number"
        },
        {
          "name": "options",
          "type": "GetLegalNaturesByCategoryOptions",
          "optional": true
        }
      ],
      "returns": "LegalNature[]",
      "cases": [
        {
          "id": "legalNature.listByCategory#category-5",
          "args": [
            "5"
          ],
          "expect": {
            "returns": [
              {
                "code": "5010",
                "description": "Organização Internacional",
                "category": {
                  "code": "5",
                  "description": "Organizações Internacionais e Outras Instituições Extraterritoriais"
                },
                "legacy": false
              },
              {
                "code": "5029",
                "description": "Representação Diplomática Estrangeira",
                "category": {
                  "code": "5",
                  "description": "Organizações Internacionais e Outras Instituições Extraterritoriais"
                },
                "legacy": false
              },
              {
                "code": "5037",
                "description": "Outras Instituições Extraterritoriais",
                "category": {
                  "code": "5",
                  "description": "Organizações Internacionais e Outras Instituições Extraterritoriais"
                },
                "legacy": false
              }
            ]
          }
        },
        {
          "id": "legalNature.listByCategory#number",
          "args": [
            5
          ],
          "expect": {
            "returns": [
              {
                "code": "5010",
                "description": "Organização Internacional",
                "category": {
                  "code": "5",
                  "description": "Organizações Internacionais e Outras Instituições Extraterritoriais"
                },
                "legacy": false
              },
              {
                "code": "5029",
                "description": "Representação Diplomática Estrangeira",
                "category": {
                  "code": "5",
                  "description": "Organizações Internacionais e Outras Instituições Extraterritoriais"
                },
                "legacy": false
              },
              {
                "code": "5037",
                "description": "Outras Instituições Extraterritoriais",
                "category": {
                  "code": "5",
                  "description": "Organizações Internacionais e Outras Instituições Extraterritoriais"
                },
                "legacy": false
              }
            ]
          }
        },
        {
          "id": "legalNature.listByCategory#category-4",
          "args": [
            "4"
          ],
          "expect": {
            "returns": [
              {
                "code": "4014",
                "description": "Empresa Individual Imobiliária",
                "category": {
                  "code": "4",
                  "description": "Pessoas Físicas"
                },
                "legacy": false
              },
              {
                "code": "4022",
                "description": "Segurado Especial",
                "category": {
                  "code": "4",
                  "description": "Pessoas Físicas"
                },
                "legacy": false
              },
              {
                "code": "4081",
                "description": "Contribuinte individual",
                "category": {
                  "code": "4",
                  "description": "Pessoas Físicas"
                },
                "legacy": false
              },
              {
                "code": "4090",
                "description": "Candidato a Cargo Político Eletivo",
                "category": {
                  "code": "4",
                  "description": "Pessoas Físicas"
                },
                "legacy": false
              },
              {
                "code": "4111",
                "description": "Leiloeiro",
                "category": {
                  "code": "4",
                  "description": "Pessoas Físicas"
                },
                "legacy": false
              },
              {
                "code": "4120",
                "description": "Produtor Rural (Pessoa Física)",
                "category": {
                  "code": "4",
                  "description": "Pessoas Físicas"
                },
                "legacy": false
              }
            ]
          }
        },
        {
          "id": "legalNature.listByCategory#[\"0\"]",
          "args": [
            "0"
          ],
          "expect": {
            "returns": []
          }
        },
        {
          "id": "legalNature.listByCategory#[\"9\"]",
          "args": [
            "9"
          ],
          "expect": {
            "returns": []
          }
        },
        {
          "id": "legalNature.listByCategory#full-code-is-not-a-category",
          "args": [
            "2062"
          ],
          "expect": {
            "returns": []
          }
        },
        {
          "id": "legalNature.listByCategory#empty",
          "args": [
            ""
          ],
          "expect": {
            "returns": []
          }
        },
        {
          "id": "legalNature.listByCategory#[4]",
          "args": [
            4
          ],
          "expect": {
            "returns": [
              {
                "code": "4014",
                "description": "Empresa Individual Imobiliária",
                "category": {
                  "code": "4",
                  "description": "Pessoas Físicas"
                },
                "legacy": false
              },
              {
                "code": "4022",
                "description": "Segurado Especial",
                "category": {
                  "code": "4",
                  "description": "Pessoas Físicas"
                },
                "legacy": false
              },
              {
                "code": "4081",
                "description": "Contribuinte individual",
                "category": {
                  "code": "4",
                  "description": "Pessoas Físicas"
                },
                "legacy": false
              },
              {
                "code": "4090",
                "description": "Candidato a Cargo Político Eletivo",
                "category": {
                  "code": "4",
                  "description": "Pessoas Físicas"
                },
                "legacy": false
              },
              {
                "code": "4111",
                "description": "Leiloeiro",
                "category": {
                  "code": "4",
                  "description": "Pessoas Físicas"
                },
                "legacy": false
              },
              {
                "code": "4120",
                "description": "Produtor Rural (Pessoa Física)",
                "category": {
                  "code": "4",
                  "description": "Pessoas Físicas"
                },
                "legacy": false
              }
            ]
          },
          "note": "JavaScript's own test: should accept the category code as a number"
        },
        {
          "id": "legalNature.listByCategory#[\"6\"]",
          "args": [
            "6"
          ],
          "expect": {
            "returns": []
          },
          "note": "JavaScript's own test: should return an empty array for a category outside 1 to 5"
        },
        {
          "id": "legalNature.listByCategory#[9]",
          "args": [
            9
          ],
          "expect": {
            "returns": []
          },
          "note": "JavaScript's own test: should return an empty array for a category outside 1 to 5"
        },
        {
          "id": "legalNature.listByCategory#[\"20\"]",
          "args": [
            "20"
          ],
          "expect": {
            "returns": []
          },
          "note": "JavaScript's own test: should return an empty array for a prefix that is not a category on its own"
        },
        {
          "id": "legalNature.listByCategory#[20]",
          "args": [
            20
          ],
          "expect": {
            "returns": []
          },
          "note": "JavaScript's own test: should return an empty array for a prefix that is not a category on its own"
        },
        {
          "id": "legalNature.listByCategory#[\" 2\"]",
          "args": [
            " 2"
          ],
          "expect": {
            "returns": []
          },
          "note": "JavaScript's own test: should return an empty array for an empty or padded category code"
        },
        {
          "id": "legalNature.listByCategory#[\"02\"]",
          "args": [
            "02"
          ],
          "expect": {
            "returns": []
          },
          "note": "JavaScript's own test: should return an empty array for an empty or padded category code"
        },
        {
          "id": "legalNature.listByCategory#[\"5\",{\"includeLegacy\":true}]",
          "args": [
            "5",
            {
              "includeLegacy": true
            }
          ],
          "expect": {
            "returns": [
              {
                "code": "5002",
                "description": "Organização Internacional e Outras Instituições Extraterritoriais",
                "category": {
                  "code": "5",
                  "description": "Organizações Internacionais e Outras Instituições Extraterritoriais"
                },
                "legacy": true,
                "currentCode": "5010"
              },
              {
                "code": "5010",
                "description": "Organização Internacional",
                "category": {
                  "code": "5",
                  "description": "Organizações Internacionais e Outras Instituições Extraterritoriais"
                },
                "legacy": false
              },
              {
                "code": "5029",
                "description": "Representação Diplomática Estrangeira",
                "category": {
                  "code": "5",
                  "description": "Organizações Internacionais e Outras Instituições Extraterritoriais"
                },
                "legacy": false
              },
              {
                "code": "5037",
                "description": "Outras Instituições Extraterritoriais",
                "category": {
                  "code": "5",
                  "description": "Organizações Internacionais e Outras Instituições Extraterritoriais"
                },
                "legacy": false
              }
            ]
          },
          "note": "JavaScript docs example: includeLegacy adds the retired 5002"
        },
        {
          "id": "legalNature.listByCategory#[\"5\",{\"includeLegacy\":false}]",
          "args": [
            "5",
            {
              "includeLegacy": false
            }
          ],
          "expect": {
            "returns": [
              {
                "code": "5010",
                "description": "Organização Internacional",
                "category": {
                  "code": "5",
                  "description": "Organizações Internacionais e Outras Instituições Extraterritoriais"
                },
                "legacy": false
              },
              {
                "code": "5029",
                "description": "Representação Diplomática Estrangeira",
                "category": {
                  "code": "5",
                  "description": "Organizações Internacionais e Outras Instituições Extraterritoriais"
                },
                "legacy": false
              },
              {
                "code": "5037",
                "description": "Outras Instituições Extraterritoriais",
                "category": {
                  "code": "5",
                  "description": "Organizações Internacionais e Outras Instituições Extraterritoriais"
                },
                "legacy": false
              }
            ]
          },
          "note": "includeLegacy: false lists only the codes in force"
        },
        {
          "id": "legalNature.listByCategory#[3,{\"includeLegacy\":true}]",
          "args": [
            3,
            {
              "includeLegacy": true
            }
          ],
          "expect": {
            "returns": [
              {
                "code": "3034",
                "description": "Serviço Notarial e Registral (Cartório)",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3042",
                "description": "Organização Social",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": true,
                "currentCode": "3069"
              },
              {
                "code": "3050",
                "description": "Organização da Sociedade Civil de Interesse Público (Oscip)",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": true,
                "currentCode": null
              },
              {
                "code": "3069",
                "description": "Fundação Privada",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3077",
                "description": "Serviço Social Autônomo",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3085",
                "description": "Condomínio Edilício",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3093",
                "description": "Unidade Executora (Programa Dinheiro Direto na Escola)",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": true,
                "currentCode": "3999"
              },
              {
                "code": "3107",
                "description": "Comissão de Conciliação Prévia",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3115",
                "description": "Entidade de Mediação e Arbitragem",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3123",
                "description": "Partido Político",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": true,
                "currentCode": null
              },
              {
                "code": "3131",
                "description": "Entidade Sindical",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3204",
                "description": "Estabelecimento, no Brasil, de Fundação ou Associação Estrangeiras",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3212",
                "description": "Fundação ou Associação Domiciliada no Exterior",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3220",
                "description": "Organização Religiosa",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3239",
                "description": "Comunidade Indígena",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3247",
                "description": "Fundo Privado",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3255",
                "description": "Órgão de Direção Nacional de Partido Político",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3263",
                "description": "Órgão de Direção Regional de Partido Político",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3271",
                "description": "Órgão de Direção Local de Partido Político",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3280",
                "description": "Comitê Financeiro de Partido Político",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3298",
                "description": "Frente Plebiscitária ou Referendária",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3301",
                "description": "Organização Social (OS)",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3310",
                "description": "Demais Condomínios",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3328",
                "description": "Plano de Benefícios de Previdência Complementar Fechada",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              },
              {
                "code": "3999",
                "description": "Associação Privada",
                "category": {
                  "code": "3",
                  "description": "Entidades sem Fins Lucrativos"
                },
                "legacy": false
              }
            ]
          },
          "note": "the number form takes options too"
        }
      ]
    },
    {
      "id": "legalNature.parse",
      "level": "extended",
      "summary": "Removes the formatting characters of a legal nature code and returns only the digits.",
      "description": "Removes legal nature formatting and keeps only digits, capped at 4 digits.\n\n- It does not left-pad anything. Returns an empty string when there is no digit at all (`null` and `undefined` included).\n- 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).",
      "params": [
        {
          "name": "value",
          "type": "string | number"
        }
      ],
      "returns": "string",
      "cases": [
        {
          "id": "legalNature.parse#masked",
          "args": [
            "206-2"
          ],
          "expect": {
            "returns": "2062"
          }
        },
        {
          "id": "legalNature.parse#unmasked",
          "args": [
            "2062"
          ],
          "expect": {
            "returns": "2062"
          }
        },
        {
          "id": "legalNature.parse#caps-length",
          "args": [
            "206299"
          ],
          "expect": {
            "returns": "2062"
          },
          "note": "reference truncates to 4 digits; asserted by the reference (JS) unit tests"
        },
        {
          "id": "legalNature.parse#empty",
          "args": [
            ""
          ],
          "expect": {
            "returns": ""
          }
        },
        {
          "id": "legalNature.parse#[206.2]",
          "args": [
            206.2
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: should return an empty string when it is a negative, fractional or unsafe number (#593 number rule)"
        },
        {
          "id": "legalNature.parse#[-1]",
          "args": [
            -1
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: should return an empty string when it is a negative, fractional or unsafe number (#593 number rule)"
        },
        {
          "id": "legalNature.parse#[1.5]",
          "args": [
            1.5
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: should return an empty string when it is a negative, fractional or unsafe number (#593 number rule)"
        }
      ]
    }
  ]
}
