{
  "$schema": "../cases.schema.json",
  "format": 1,
  "domain": "cnpj",
  "title": {
    "en": "CNPJ",
    "pt-BR": "CNPJ"
  },
  "functions": [
    {
      "id": "cnpj.format",
      "level": "core",
      "summary": "Formats a CNPJ value with the given options.",
      "description": "Formats a CNPJ as `00.000.000/0000-00`.\n\n- `options.pad` first left-pads the value with zeros to 14 characters.\n- `options.version`: `1` (default) keeps digits only. `2` (alphanumeric CNPJ) keeps letters (upper-cased) and digits. Any other value is read as `1`.\n- `options.obfuscate` (default `false`, read for truthiness like `pad`) hides the first 2 characters and the 2 check digits with `*`, after padding. This is a convention of the library, with no official source: no law or Receita Federal act sets a masking rule for the CNPJ, whose data are public. It follows the rule the Leis de Diretrizes Orçamentárias set for the CPF.\n- 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).\n- A value with no characters the version keeps (empty, or only symbols) returns an empty string even with `options.pad`. Until 2.4.0 `pad` returned the whole zero mask (`00.000.000/0000-00`).\n- The value is read up to 14 characters: characters past the 14th are dropped, also with `options.pad`.\n- Since July 2026 new CNPJs may be alphanumeric. The default `version: 1` drops their letters, so pass `version: 2` to keep them. A number loses its leading zeros: pass a string, or use `options.pad`, for a CNPJ that starts with `0`.\n- Pending decision (findings §2 #2, #3): 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`.",
      "params": [
        {
          "name": "value",
          "type": "string | number"
        },
        {
          "name": "options",
          "type": "FormatCnpjOptions",
          "optional": true
        }
      ],
      "returns": "string",
      "cases": [
        {
          "id": "cnpj.format#[\"10799163989271\"]",
          "args": [
            "10799163989271"
          ],
          "expect": {
            "returns": "10.799.163/9892-71"
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "cnpj.format#[\"64977017647333\"]",
          "args": [
            "64977017647333"
          ],
          "expect": {
            "returns": "64.977.017/6473-33"
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "cnpj.format#[\"62932200808587\"]",
          "args": [
            "62932200808587"
          ],
          "expect": {
            "returns": "62.932.200/8085-87"
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "cnpj.format#[\"\"]",
          "args": [
            ""
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[\"4\"]",
          "args": [
            "4"
          ],
          "expect": {
            "returns": "4"
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[\"46\"]",
          "args": [
            "46"
          ],
          "expect": {
            "returns": "46"
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[\"468\"]",
          "args": [
            "468"
          ],
          "expect": {
            "returns": "46.8"
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[\"4684\"]",
          "args": [
            "4684"
          ],
          "expect": {
            "returns": "46.84"
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[\"46843\"]",
          "args": [
            "46843"
          ],
          "expect": {
            "returns": "46.843"
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[\"468434\"]",
          "args": [
            "468434"
          ],
          "expect": {
            "returns": "46.843.4"
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[\"4684348\"]",
          "args": [
            "4684348"
          ],
          "expect": {
            "returns": "46.843.48"
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[\"46843485\"]",
          "args": [
            "46843485"
          ],
          "expect": {
            "returns": "46.843.485"
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[\"468434850\"]",
          "args": [
            "468434850"
          ],
          "expect": {
            "returns": "46.843.485/0"
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[\"4684348500\"]",
          "args": [
            "4684348500"
          ],
          "expect": {
            "returns": "46.843.485/00"
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[\"46843485000\"]",
          "args": [
            "46843485000"
          ],
          "expect": {
            "returns": "46.843.485/000"
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[\"468434850001\"]",
          "args": [
            "468434850001"
          ],
          "expect": {
            "returns": "46.843.485/0001"
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[\"4684348500018\"]",
          "args": [
            "4684348500018"
          ],
          "expect": {
            "returns": "46.843.485/0001-8"
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[\"46843485000186\"]",
          "args": [
            "46843485000186"
          ],
          "expect": {
            "returns": "46.843.485/0001-86"
          },
          "note": "JavaScript's own test: should format cnpj with mask"
        },
        {
          "id": "cnpj.format#[4]",
          "args": [
            4
          ],
          "expect": {
            "returns": "4"
          },
          "note": "JavaScript's own test: should format number cnpj with mask"
        },
        {
          "id": "cnpj.format#[46]",
          "args": [
            46
          ],
          "expect": {
            "returns": "46"
          },
          "note": "JavaScript's own test: should format number cnpj with mask"
        },
        {
          "id": "cnpj.format#[468]",
          "args": [
            468
          ],
          "expect": {
            "returns": "46.8"
          },
          "note": "JavaScript's own test: should format number cnpj with mask"
        },
        {
          "id": "cnpj.format#[4684]",
          "args": [
            4684
          ],
          "expect": {
            "returns": "46.84"
          },
          "note": "JavaScript's own test: should format number cnpj with mask"
        },
        {
          "id": "cnpj.format#[46843]",
          "args": [
            46843
          ],
          "expect": {
            "returns": "46.843"
          },
          "note": "JavaScript's own test: should format number cnpj with mask"
        },
        {
          "id": "cnpj.format#[468434]",
          "args": [
            468434
          ],
          "expect": {
            "returns": "46.843.4"
          },
          "note": "JavaScript's own test: should format number cnpj with mask"
        },
        {
          "id": "cnpj.format#[4684348]",
          "args": [
            4684348
          ],
          "expect": {
            "returns": "46.843.48"
          },
          "note": "JavaScript's own test: should format number cnpj with mask"
        },
        {
          "id": "cnpj.format#[46843485]",
          "args": [
            46843485
          ],
          "expect": {
            "returns": "46.843.485"
          },
          "note": "JavaScript's own test: should format number cnpj with mask"
        },
        {
          "id": "cnpj.format#[468434850]",
          "args": [
            468434850
          ],
          "expect": {
            "returns": "46.843.485/0"
          },
          "note": "JavaScript's own test: should format number cnpj with mask"
        },
        {
          "id": "cnpj.format#[4684348500]",
          "args": [
            4684348500
          ],
          "expect": {
            "returns": "46.843.485/00"
          },
          "note": "JavaScript's own test: should format number cnpj with mask"
        },
        {
          "id": "cnpj.format#[46843485000]",
          "args": [
            46843485000
          ],
          "expect": {
            "returns": "46.843.485/000"
          },
          "note": "JavaScript's own test: should format number cnpj with mask"
        },
        {
          "id": "cnpj.format#[468434850001]",
          "args": [
            468434850001
          ],
          "expect": {
            "returns": "46.843.485/0001"
          },
          "note": "JavaScript's own test: should format number cnpj with mask"
        },
        {
          "id": "cnpj.format#[4684348500018]",
          "args": [
            4684348500018
          ],
          "expect": {
            "returns": "46.843.485/0001-8"
          },
          "note": "JavaScript's own test: should format number cnpj with mask"
        },
        {
          "id": "cnpj.format#[46843485000186]",
          "args": [
            46843485000186
          ],
          "expect": {
            "returns": "46.843.485/0001-86"
          },
          "note": "JavaScript's own test: should format number cnpj with mask"
        },
        {
          "id": "cnpj.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 gave 00.000.000/0000-00)"
        },
        {
          "id": "cnpj.format#[\"4\",{\"pad\":true}]",
          "args": [
            "4",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.000/0000-04"
          },
          "note": "JavaScript's own test: should format cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[\"46\",{\"pad\":true}]",
          "args": [
            "46",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.000/0000-46"
          },
          "note": "JavaScript's own test: should format cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[\"468\",{\"pad\":true}]",
          "args": [
            "468",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.000/0004-68"
          },
          "note": "JavaScript's own test: should format cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[\"4684\",{\"pad\":true}]",
          "args": [
            "4684",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.000/0046-84"
          },
          "note": "JavaScript's own test: should format cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[\"46843\",{\"pad\":true}]",
          "args": [
            "46843",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.000/0468-43"
          },
          "note": "JavaScript's own test: should format cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[\"468434\",{\"pad\":true}]",
          "args": [
            "468434",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.000/4684-34"
          },
          "note": "JavaScript's own test: should format cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[\"4684348\",{\"pad\":true}]",
          "args": [
            "4684348",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.004/6843-48"
          },
          "note": "JavaScript's own test: should format cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[\"46843485\",{\"pad\":true}]",
          "args": [
            "46843485",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.046/8434-85"
          },
          "note": "JavaScript's own test: should format cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[\"468434850\",{\"pad\":true}]",
          "args": [
            "468434850",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.468/4348-50"
          },
          "note": "JavaScript's own test: should format cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[\"4684348500\",{\"pad\":true}]",
          "args": [
            "4684348500",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.004.684/3485-00"
          },
          "note": "JavaScript's own test: should format cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[\"46843485000\",{\"pad\":true}]",
          "args": [
            "46843485000",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.046.843/4850-00"
          },
          "note": "JavaScript's own test: should format cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[\"468434850001\",{\"pad\":true}]",
          "args": [
            "468434850001",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.468.434/8500-01"
          },
          "note": "JavaScript's own test: should format cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[\"4684348500018\",{\"pad\":true}]",
          "args": [
            "4684348500018",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "04.684.348/5000-18"
          },
          "note": "JavaScript's own test: should format cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[\"46843485000186\",{\"pad\":true}]",
          "args": [
            "46843485000186",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "46.843.485/0001-86"
          },
          "note": "JavaScript's own test: should format cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[4,{\"pad\":true}]",
          "args": [
            4,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.000/0000-04"
          },
          "note": "JavaScript's own test: should format number cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[46,{\"pad\":true}]",
          "args": [
            46,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.000/0000-46"
          },
          "note": "JavaScript's own test: should format number cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[468,{\"pad\":true}]",
          "args": [
            468,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.000/0004-68"
          },
          "note": "JavaScript's own test: should format number cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[4684,{\"pad\":true}]",
          "args": [
            4684,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.000/0046-84"
          },
          "note": "JavaScript's own test: should format number cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[46843,{\"pad\":true}]",
          "args": [
            46843,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.000/0468-43"
          },
          "note": "JavaScript's own test: should format number cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[468434,{\"pad\":true}]",
          "args": [
            468434,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.000/4684-34"
          },
          "note": "JavaScript's own test: should format number cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[4684348,{\"pad\":true}]",
          "args": [
            4684348,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.004/6843-48"
          },
          "note": "JavaScript's own test: should format number cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[46843485,{\"pad\":true}]",
          "args": [
            46843485,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.046/8434-85"
          },
          "note": "JavaScript's own test: should format number cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[468434850,{\"pad\":true}]",
          "args": [
            468434850,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.000.468/4348-50"
          },
          "note": "JavaScript's own test: should format number cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[4684348500,{\"pad\":true}]",
          "args": [
            4684348500,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.004.684/3485-00"
          },
          "note": "JavaScript's own test: should format number cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[46843485000,{\"pad\":true}]",
          "args": [
            46843485000,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.046.843/4850-00"
          },
          "note": "JavaScript's own test: should format number cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[468434850001,{\"pad\":true}]",
          "args": [
            468434850001,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.468.434/8500-01"
          },
          "note": "JavaScript's own test: should format number cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[4684348500018,{\"pad\":true}]",
          "args": [
            4684348500018,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "04.684.348/5000-18"
          },
          "note": "JavaScript's own test: should format number cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[46843485000186,{\"pad\":true}]",
          "args": [
            46843485000186,
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "46.843.485/0001-86"
          },
          "note": "JavaScript's own test: should format number cnpj with mask filling zeroes"
        },
        {
          "id": "cnpj.format#[\"468434850001860000000000\"]",
          "args": [
            "468434850001860000000000"
          ],
          "expect": {
            "returns": "46.843.485/0001-86"
          },
          "note": "JavaScript's own test"
        },
        {
          "id": "cnpj.format#[\"46.?ABC843.485/0001-86abc\"]",
          "args": [
            "46.?ABC843.485/0001-86abc"
          ],
          "expect": {
            "returns": "46.843.485/0001-86"
          },
          "note": "JavaScript's own test: should remove all non numeric characters"
        },
        {
          "id": "cnpj.format#[\"\",{\"version\":2}]",
          "args": [
            "",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"Q\",{\"version\":2}]",
          "args": [
            "Q",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q"
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"Q0\",{\"version\":2}]",
          "args": [
            "Q0",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0"
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"Q0S\",{\"version\":2}]",
          "args": [
            "Q0S",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0.S"
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"Q0SL\",{\"version\":2}]",
          "args": [
            "Q0SL",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0.SL"
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"Q0SLF\",{\"version\":2}]",
          "args": [
            "Q0SLF",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0.SLF"
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"Q0SLFM\",{\"version\":2}]",
          "args": [
            "Q0SLFM",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0.SLF.M"
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"Q0SLFMB\",{\"version\":2}]",
          "args": [
            "Q0SLFMB",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0.SLF.MB"
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"Q0SLFMBD\",{\"version\":2}]",
          "args": [
            "Q0SLFMBD",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0.SLF.MBD"
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"Q0SLFMBD7\",{\"version\":2}]",
          "args": [
            "Q0SLFMBD7",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0.SLF.MBD/7"
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"Q0SLFMBD7V\",{\"version\":2}]",
          "args": [
            "Q0SLFMBD7V",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0.SLF.MBD/7V"
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"Q0SLFMBD7VX\",{\"version\":2}]",
          "args": [
            "Q0SLFMBD7VX",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0.SLF.MBD/7VX"
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"Q0SLFMBD7VX4\",{\"version\":2}]",
          "args": [
            "Q0SLFMBD7VX4",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0.SLF.MBD/7VX4"
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"Q0SLFMBD7VX43\",{\"version\":2}]",
          "args": [
            "Q0SLFMBD7VX43",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0.SLF.MBD/7VX4-3"
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"q0SLFMBD7VX439\",{\"version\":2}]",
          "args": [
            "q0SLFMBD7VX439",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0.SLF.MBD/7VX4-39"
          },
          "note": "JavaScript's own test: should format cnpj alphanumeric with mask for version 2"
        },
        {
          "id": "cnpj.format#[\"46.?ABC843.485/0001-86abc\",{\"version\":2}]",
          "args": [
            "46.?ABC843.485/0001-86abc",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "46.ABC.843/4850-00"
          },
          "note": "JavaScript's own test: should remove non-alphanumeric characters for version 2"
        },
        {
          "id": "cnpj.format#[\"12ABC34501DE35\",{\"version\":2}]",
          "args": [
            "12ABC34501DE35",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "12.ABC.345/01DE-35"
          },
          "note": "JavaScript's own test: should allow all alphabet letters for version 2 (including E, O, T, U)"
        },
        {
          "id": "cnpj.format#[\"12.ABC.345/01DE-35\",{\"version\":2}]",
          "args": [
            "12.ABC.345/01DE-35",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "12.ABC.345/01DE-35"
          },
          "note": "JavaScript's own test: should allow all alphabet letters for version 2 (including E, O, T, U)"
        },
        {
          "id": "cnpj.format#[\"12OUT345000199\",{\"version\":2}]",
          "args": [
            "12OUT345000199",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "12.OUT.345/0001-99"
          },
          "note": "JavaScript's own test: should allow all alphabet letters for version 2 (including E, O, T, U)"
        },
        {
          "id": "cnpj.format#[\"46843485000186\",{\"obfuscate\":true}]",
          "args": [
            "46843485000186",
            {
              "obfuscate": true
            }
          ],
          "expect": {
            "returns": "**.843.485/0001-**"
          },
          "note": "JavaScript's own test: should hide the first 2 digits and the 2 check digits when obfuscate is true"
        },
        {
          "id": "cnpj.format#[46843485000186,{\"obfuscate\":true}]",
          "args": [
            46843485000186,
            {
              "obfuscate": true
            }
          ],
          "expect": {
            "returns": "**.843.485/0001-**"
          },
          "note": "JavaScript's own test: should hide the first 2 digits and the 2 check digits when obfuscate is true"
        },
        {
          "id": "cnpj.format#[\"4\",{\"pad\":true,\"obfuscate\":true}]",
          "args": [
            "4",
            {
              "pad": true,
              "obfuscate": true
            }
          ],
          "expect": {
            "returns": "**.000.000/0000-**"
          },
          "note": "JavaScript's own test: should pad before obfuscating"
        },
        {
          "id": "cnpj.format#[\"q0SLFMBD7VX439\",{\"version\":2,\"obfuscate\":true}]",
          "args": [
            "q0SLFMBD7VX439",
            {
              "version": 2,
              "obfuscate": true
            }
          ],
          "expect": {
            "returns": "**.SLF.MBD/7VX4-**"
          },
          "note": "JavaScript's own test: should apply the same positions to the alphanumeric CNPJ (version 2)"
        },
        {
          "id": "cnpj.format#[\"46843485000186\",{\"obfuscate\":false}]",
          "args": [
            "46843485000186",
            {
              "obfuscate": false
            }
          ],
          "expect": {
            "returns": "46.843.485/0001-86"
          },
          "note": "JavaScript's own test: should behave exactly as without the option when obfuscate is false or absent"
        },
        {
          "id": "cnpj.format#[\"q0SLFMBD7VX439\",{\"version\":2,\"obfuscate\":false}]",
          "args": [
            "q0SLFMBD7VX439",
            {
              "version": 2,
              "obfuscate": false
            }
          ],
          "expect": {
            "returns": "Q0.SLF.MBD/7VX4-39"
          },
          "note": "JavaScript's own test: should behave exactly as without the option when obfuscate is false or absent"
        },
        {
          "id": "cnpj.format#[\"q0slfmbd7vx439\",{\"version\":2}]",
          "args": [
            "q0slfmbd7vx439",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0.SLF.MBD/7VX4-39"
          },
          "note": "JavaScript's own test: should upper-case lower case letters for version 2, the official set being A to Z"
        },
        {
          "id": "cnpj.format#[\"12abc34501de35\",{\"version\":2}]",
          "args": [
            "12abc34501de35",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "12.ABC.345/01DE-35"
          },
          "note": "JavaScript's own test: should upper-case lower case letters for version 2, the official set being A to Z"
        },
        {
          "id": "cnpj.format#[-11222333000181]",
          "args": [
            -11222333000181
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's JSDoc example; changed in 2.5.0 (#593): a number is read only when it is a non-negative safe integer"
        },
        {
          "id": "cnpj.format#[-1]",
          "args": [
            -1
          ],
          "expect": {
            "returns": ""
          },
          "note": "changed in 2.5.0 (#593): a number is read only when it is a non-negative safe integer"
        },
        {
          "id": "cnpj.format#[1.5]",
          "args": [
            1.5
          ],
          "expect": {
            "returns": ""
          },
          "note": "changed in 2.5.0 (#593): a number is read only when it is a non-negative safe integer"
        },
        {
          "id": "cnpj.format#[9007199254740992]",
          "args": [
            9007199254740992
          ],
          "expect": {
            "returns": ""
          },
          "note": "changed in 2.5.0 (#593): a number is read only when it is a non-negative safe integer"
        },
        {
          "id": "cnpj.format#[\"abc\",{\"pad\":true}]",
          "args": [
            "abc",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: should return an empty string for a value without digits even when padding"
        },
        {
          "id": "cnpj.format#[\"24522200000174\"]",
          "args": [
            "24522200000174"
          ],
          "expect": {
            "returns": "24.522.200/0001-74"
          },
          "note": "JavaScript docs example"
        },
        {
          "id": "cnpj.format#[\"245222000174\",{\"pad\":true}]",
          "args": [
            "245222000174",
            {
              "pad": true
            }
          ],
          "expect": {
            "returns": "00.245.222/0001-74"
          },
          "note": "JavaScript docs example"
        },
        {
          "id": "cnpj.format#[\"12345678000195\",{\"obfuscate\":true}]",
          "args": [
            "12345678000195",
            {
              "obfuscate": true
            }
          ],
          "expect": {
            "returns": "**.345.678/0001-**"
          },
          "note": "JavaScript docs example"
        },
        {
          "id": "cnpj.format#[\"12OUT345000199\"]",
          "args": [
            "12OUT345000199"
          ],
          "expect": {
            "returns": "12.345.000/199"
          },
          "note": "docs note: the default version 1 keeps digits only, so the letters of an alphanumeric CNPJ are dropped and the rest is masked as a partial value"
        }
      ]
    },
    {
      "id": "cnpj.generate",
      "level": "core",
      "summary": "Generates a valid random CNPJ.",
      "description": "Generates a valid random CNPJ, unformatted.\n\n- `versionOrParams` picks the version: `1` (default, numeric) or `2` (alphanumeric). It can also be an object `{ version, branch }`, where `branch` sets the branch (número de ordem), an integer from 1 to 9999. The branch is random by default, and an invalid branch is ignored.\n- A branch given in `branch` is written as 4 digits in both versions (`3` gives `0003`). A random branch under version 2 can carry letters, like the root.\n- A random branch is never `0000`: the establishments of a root are numbered from `0001`, the headquarters (matriz). 2.4.0 could return `0000`, about once in 10,000 numeric CNPJs.\n- Invalid `branch` values (0, above 9999, fractional, not a number) are ignored and a random branch is used. A number `versionOrParams` other than `2` (or a value that is neither `2` nor an object) generates a numeric CNPJ.",
      "params": [
        {
          "name": "versionOrParams",
          "type": "1 | 2 | GenerateCnpjParams",
          "optional": true
        }
      ],
      "returns": "string",
      "cases": [
        {
          "id": "cnpj.generate#generated-is-valid",
          "args": [],
          "expect": {
            "satisfies": "cnpj.isValid"
          },
          "repeat": 5,
          "note": "every generated value must pass the lib's own validator"
        },
        {
          "id": "cnpj.generate#branch-never-0000",
          "args": [],
          "expect": {
            "matches": "^[0-9]{8}([1-9][0-9]{3}|0[1-9][0-9]{2}|00[1-9][0-9]|000[1-9])[0-9]{2}$"
          },
          "repeat": 20,
          "note": "changed in 2.5.0 (#593): generateCnpj never draws the branch 0000"
        },
        {
          "id": "cnpj.generate#given-branch",
          "args": [
            {
              "branch": 3
            }
          ],
          "expect": {
            "matches": "^[0-9]{8}0003[0-9]{2}$"
          },
          "repeat": 5,
          "note": "JavaScript's JSDoc example: generateCnpj({ branch: 3 }), the ordem block is 0003"
        },
        {
          "id": "cnpj.generate#version-2-branch-never-0000",
          "args": [
            2
          ],
          "expect": {
            "matches": "^[0-9A-Z]{8}([1-9A-Z][0-9A-Z]{3}|0[1-9A-Z][0-9A-Z]{2}|00[1-9A-Z][0-9A-Z]|000[1-9A-Z])[0-9]{2}$"
          },
          "repeat": 20,
          "note": "changed in 2.5.0 (#593): generateCnpj never draws the branch 0000 (under version 2 a random branch can carry letters)"
        },
        {
          "id": "cnpj.generate#[{\"version\":2,\"branch\":1}]",
          "args": [
            {
              "version": 2,
              "branch": 1
            }
          ],
          "expect": {
            "matches": "^[0-9A-Z]{8}0001[0-9]{2}$"
          },
          "note": "JavaScript docs example: generateCnpj({ version: 2, branch: 1 }), the ordem block is 0001"
        },
        {
          "id": "cnpj.generate#[{\"branch\":0}]",
          "args": [
            {
              "branch": 0
            }
          ],
          "expect": {
            "matches": "^[0-9]{14}$"
          },
          "note": "JavaScript docs example: generateCnpj({ branch: 0 }), an out of range branch draws a random block"
        },
        {
          "id": "cnpj.generate#[{\"branch\":9999}]",
          "args": [
            {
              "branch": 9999
            }
          ],
          "expect": {
            "matches": "^[0-9]{8}9999[0-9]{2}$"
          },
          "note": "JavaScript's own test: should write the branch as the ordem block in positions 9 to 12"
        },
        {
          "id": "cnpj.generate#[{\"branch\":42}]",
          "args": [
            {
              "branch": 42
            }
          ],
          "expect": {
            "matches": "^[0-9]{8}0042[0-9]{2}$"
          },
          "note": "JavaScript's own test: should zero pad a branch shorter than the four character ordem block"
        },
        {
          "id": "cnpj.generate#[2]",
          "args": [
            2
          ],
          "expect": {
            "matches": "^[0-9A-Z]{14}$"
          },
          "note": "JavaScript docs example: generateCnpj(2), an alphanumeric CNPJ"
        }
      ]
    },
    {
      "id": "cnpj.getInfo",
      "level": "extended",
      "summary": "Reads the root, branch and check digits of a CNPJ.",
      "description": "Reads the fields of a CNPJ: root, branch and check digits, and whether the branch is `0001`. Returns `null` exactly when `cnpj.isValid` is `false` for the same arguments.\n\n- `root` is positions 1 to 8. `branch` is positions 9 to 12, the número de ordem of the establishment. `checkDigits` is positions 13 and 14. The name `branch` is the same as in `cnpj.generate`.\n- `options.version` works as in `cnpj.isValid`: `1` (default) reads numeric CNPJs only, `2` reads numeric and alphanumeric CNPJs, and any other value is read as `1`. An alphanumeric CNPJ read under version 1 returns `null`.\n- The fields of an alphanumeric CNPJ come back in upper case.\n- `isInitialHeadquarters` is `true` when the branch is `0001`. It marks the headquarters (matriz) only at the time the CNPJ was created: a filial can become the matriz without having the branch `0001` (question 25 of the Receita Federal Q&A on the alphanumeric CNPJ). Only the Receita Federal registry tells the current headquarters.\n- The result has no `format` field. Use `cnpj.format` for the mask.\n- Returns a new object on every call.",
      "params": [
        {
          "name": "value",
          "type": "string"
        },
        {
          "name": "options",
          "type": "GetCnpjInfoOptions",
          "optional": true
        }
      ],
      "returns": "CnpjInfo?",
      "cases": [
        {
          "id": "cnpj.getInfo#[\"12.345.678/0001-95\"]",
          "args": [
            "12.345.678/0001-95"
          ],
          "expect": {
            "returns": {
              "root": "12345678",
              "branch": "0001",
              "checkDigits": "95",
              "isInitialHeadquarters": true
            }
          },
          "note": "from the maintainer briefing, #560"
        },
        {
          "id": "cnpj.getInfo#[\"12.abc.345/01de-35\",{\"version\":2}]",
          "args": [
            "12.abc.345/01de-35",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": {
              "root": "12ABC345",
              "branch": "01DE",
              "checkDigits": "35",
              "isInitialHeadquarters": false
            }
          },
          "note": "from the maintainer briefing, #560"
        },
        {
          "id": "cnpj.getInfo#[\"12.ABC.345/01DE-35\"]",
          "args": [
            "12.ABC.345/01DE-35"
          ],
          "expect": {
            "returns": null
          },
          "note": "from the maintainer briefing, #560 (alphanumeric read under version 1)"
        },
        {
          "id": "cnpj.getInfo#[\"12345678000195\"]",
          "args": [
            "12345678000195"
          ],
          "expect": {
            "returns": {
              "root": "12345678",
              "branch": "0001",
              "checkDigits": "95",
              "isInitialHeadquarters": true
            }
          },
          "note": "JavaScript's own test: should return the fields of the CNPJ for the headquarters branch"
        },
        {
          "id": "cnpj.getInfo#[\"12345678000276\"]",
          "args": [
            "12345678000276"
          ],
          "expect": {
            "returns": {
              "root": "12345678",
              "branch": "0002",
              "checkDigits": "76",
              "isInitialHeadquarters": false
            }
          },
          "note": "JavaScript's own test: should return the fields of the CNPJ for another branch"
        },
        {
          "id": "cnpj.getInfo#[\"00000001000136\"]",
          "args": [
            "00000001000136"
          ],
          "expect": {
            "returns": {
              "root": "00000001",
              "branch": "0001",
              "checkDigits": "36",
              "isInitialHeadquarters": true
            }
          },
          "note": "JavaScript's own test: should return the fields of the CNPJ for a root with leading zeros"
        },
        {
          "id": "cnpj.getInfo#[\"  12 345 678 0002 76  \"]",
          "args": [
            "  12 345 678 0002 76  "
          ],
          "expect": {
            "returns": {
              "root": "12345678",
              "branch": "0002",
              "checkDigits": "76",
              "isInitialHeadquarters": false
            }
          },
          "note": "JavaScript's own test: should return the fields of the CNPJ for a value with a whitespace mask and surrounding whitespace"
        },
        {
          "id": "cnpj.getInfo#[\"12.345.678/0001-95\",{\"version\":2}]",
          "args": [
            "12.345.678/0001-95",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": {
              "root": "12345678",
              "branch": "0001",
              "checkDigits": "95",
              "isInitialHeadquarters": true
            }
          },
          "note": "JavaScript's own test: should return the fields of the CNPJ under version 2, which reads both formats"
        },
        {
          "id": "cnpj.getInfo#[\"12345678000195\",{\"version\":3}]",
          "args": [
            "12345678000195",
            {
              "version": 3
            }
          ],
          "expect": {
            "returns": {
              "root": "12345678",
              "branch": "0001",
              "checkDigits": "95",
              "isInitialHeadquarters": true
            }
          },
          "note": "JavaScript's own test: should return the fields of the CNPJ under an unknown version, read as version 1"
        },
        {
          "id": "cnpj.getInfo#[\"12.ABC.345/01DE-35\",{\"version\":2}]",
          "args": [
            "12.ABC.345/01DE-35",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": {
              "root": "12ABC345",
              "branch": "01DE",
              "checkDigits": "35",
              "isInitialHeadquarters": false
            }
          },
          "note": "JavaScript's own test: should return the fields of the CNPJ for the example of the Receita Federal check digit manual"
        },
        {
          "id": "cnpj.getInfo#[\"12abc34501de35\",{\"version\":2}]",
          "args": [
            "12abc34501de35",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": {
              "root": "12ABC345",
              "branch": "01DE",
              "checkDigits": "35",
              "isInitialHeadquarters": false
            }
          },
          "note": "JavaScript's own test: should return the fields of the CNPJ for a lowercase value, upper casing the fields"
        },
        {
          "id": "cnpj.getInfo#[\"AB.12C.D34/0001-84\",{\"version\":2}]",
          "args": [
            "AB.12C.D34/0001-84",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": {
              "root": "AB12CD34",
              "branch": "0001",
              "checkDigits": "84",
              "isInitialHeadquarters": true
            }
          },
          "note": "JavaScript's own test: should return the fields of the CNPJ for an alphanumeric root with the headquarters branch"
        },
        {
          "id": "cnpj.getInfo#[\"AA345678/000A-29\",{\"version\":2}]",
          "args": [
            "AA345678/000A-29",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": {
              "root": "AA345678",
              "branch": "000A",
              "checkDigits": "29",
              "isInitialHeadquarters": false
            }
          },
          "note": "JavaScript's own test: should return the fields of the CNPJ for an alphanumeric root and branch (Receita Federal Q&A, question 23)"
        },
        {
          "id": "cnpj.getInfo#[\"12.345.678/000A-08\",{\"version\":2}]",
          "args": [
            "12.345.678/000A-08",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": {
              "root": "12345678",
              "branch": "000A",
              "checkDigits": "08",
              "isInitialHeadquarters": false
            }
          },
          "note": "JavaScript's own test: should return the fields of the CNPJ for a numeric root with an alphanumeric branch (Receita Federal Q&A, question 23)"
        },
        {
          "id": "cnpj.getInfo#[\"12.ABC.345/01DE-35\",{}]",
          "args": [
            "12.ABC.345/01DE-35",
            {}
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when an alphanumeric CNPJ is read under the default version"
        },
        {
          "id": "cnpj.getInfo#[\"12.ABC.345/01DE-35\",{\"version\":1}]",
          "args": [
            "12.ABC.345/01DE-35",
            {
              "version": 1
            }
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when an alphanumeric CNPJ is read under the default version"
        },
        {
          "id": "cnpj.getInfo#[\"12345678000190\"]",
          "args": [
            "12345678000190"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the check digits do not match"
        },
        {
          "id": "cnpj.getInfo#[\"12ABC34501DE34\",{\"version\":2}]",
          "args": [
            "12ABC34501DE34",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the check digits do not match"
        },
        {
          "id": "cnpj.getInfo#[\"12ABC34501DE3A\",{\"version\":2}]",
          "args": [
            "12ABC34501DE3A",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when a check digit is a letter"
        },
        {
          "id": "cnpj.getInfo#[\"00000000000000\"]",
          "args": [
            "00000000000000"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is a reserved repeated digits number"
        },
        {
          "id": "cnpj.getInfo#[\"11111111111111\",{\"version\":2}]",
          "args": [
            "11111111111111",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is a reserved repeated digits number"
        },
        {
          "id": "cnpj.getInfo#[\"1234567800019\"]",
          "args": [
            "1234567800019"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is shorter or longer than 14 characters"
        },
        {
          "id": "cnpj.getInfo#[\"123456780001955\"]",
          "args": [
            "123456780001955"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is shorter or longer than 14 characters"
        },
        {
          "id": "cnpj.getInfo#[\"12.345.678/0001-95x\"]",
          "args": [
            "12.345.678/0001-95x"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it carries a character outside the mask"
        },
        {
          "id": "cnpj.getInfo#[\"12_345_678_0001_95\"]",
          "args": [
            "12_345_678_0001_95"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it carries a character outside the mask"
        },
        {
          "id": "cnpj.getInfo#[\"\"]",
          "args": [
            ""
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is an empty string"
        }
      ]
    },
    {
      "id": "cnpj.isValid",
      "level": "core",
      "summary": "Validates a CNPJ, numeric (version 1) or alphanumeric (version 2).",
      "description": "Validates a CNPJ: 12 base characters and 2 modulus 11 check digits.\n\n- `options.version`: `1` (default) accepts numeric CNPJs only. `2` also accepts the alphanumeric CNPJ, case-insensitively. Any other value is read as `1`.\n- A numeric CNPJ whose digits are all the same is rejected. The alphanumeric format has no reserved list.\n- Since July 2026 new CNPJs may be alphanumeric, which the default `version: 1` rejects. Pass `version: 2` to accept them.\n- The official character set of the alphanumeric CNPJ is the capital letters `A` to `Z` and the digits; the 2 check digits are always digits. A lower case letter is accepted only as input normalization, like a mask character: the value is upper-cased first.\n- The Ex1 of question 23 of the Receita Federal Q&A on the alphanumeric CNPJ, `AA345678/0003-29`, is a misprint: its check digits are `86`, so it is rejected.\n- Pending decision (findings §2 #1): the reference (JS) ignores the formatting characters (`.`, `-`, `/`) and whitespace around and between groups. The other libraries accept digits only.",
      "params": [
        {
          "name": "cnpj",
          "type": "string"
        },
        {
          "name": "options",
          "type": "IsValidCnpjOptions",
          "optional": true
        }
      ],
      "returns": "boolean",
      "cases": [
        {
          "id": "cnpj.isValid#[\"10799163989271\"]",
          "args": [
            "10799163989271"
          ],
          "expect": {
            "returns": true
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "cnpj.isValid#[\"10799163989272\"]",
          "args": [
            "10799163989272"
          ],
          "expect": {
            "returns": false
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "cnpj.isValid#[\"00000000000000\"]",
          "args": [
            "00000000000000"
          ],
          "expect": {
            "returns": false
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "cnpj.isValid#[\"64977017647333\"]",
          "args": [
            "64977017647333"
          ],
          "expect": {
            "returns": true
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "cnpj.isValid#[\"64977017647334\"]",
          "args": [
            "64977017647334"
          ],
          "expect": {
            "returns": false
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "cnpj.isValid#[\"62932200808587\"]",
          "args": [
            "62932200808587"
          ],
          "expect": {
            "returns": true
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "cnpj.isValid#[\"62932200808588\"]",
          "args": [
            "62932200808588"
          ],
          "expect": {
            "returns": false
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "cnpj.isValid#[\"\"]",
          "args": [
            ""
          ],
          "expect": {
            "returns": false
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "cnpj.isValid#[\"   \"]",
          "args": [
            "   "
          ],
          "expect": {
            "returns": false
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "cnpj.isValid#[\"abc\"]",
          "args": [
            "abc"
          ],
          "expect": {
            "returns": false
          },
          "note": "consensus of 5 libs (go, javascript, python, ruby, rust)"
        },
        {
          "id": "cnpj.isValid#[\"11111111111111\"]",
          "args": [
            "11111111111111"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when every digit is the same"
        },
        {
          "id": "cnpj.isValid#[\"22222222222222\"]",
          "args": [
            "22222222222222"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when every digit is the same"
        },
        {
          "id": "cnpj.isValid#[\"33333333333333\"]",
          "args": [
            "33333333333333"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when every digit is the same"
        },
        {
          "id": "cnpj.isValid#[\"44444444444444\"]",
          "args": [
            "44444444444444"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when every digit is the same"
        },
        {
          "id": "cnpj.isValid#[\"55555555555555\"]",
          "args": [
            "55555555555555"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when every digit is the same"
        },
        {
          "id": "cnpj.isValid#[\"66666666666666\"]",
          "args": [
            "66666666666666"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when every digit is the same"
        },
        {
          "id": "cnpj.isValid#[\"77777777777777\"]",
          "args": [
            "77777777777777"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when every digit is the same"
        },
        {
          "id": "cnpj.isValid#[\"88888888888888\"]",
          "args": [
            "88888888888888"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when every digit is the same"
        },
        {
          "id": "cnpj.isValid#[\"99999999999999\"]",
          "args": [
            "99999999999999"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when every digit is the same"
        },
        {
          "id": "cnpj.isValid#[\"12312312312\"]",
          "args": [
            "12312312312"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false"
        },
        {
          "id": "cnpj.isValid#[\"ababcabcabcdab\"]",
          "args": [
            "ababcabcabcdab"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when contains only letters or special characters"
        },
        {
          "id": "cnpj.isValid#[\"6ad0.t391.9asd47/0ad001-00\"]",
          "args": [
            "6ad0.t391.9asd47/0ad001-00"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when is a CNPJ invalid test numbers with letters"
        },
        {
          "id": "cnpj.isValid#[\"11257245286531\"]",
          "args": [
            "11257245286531"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when is a CNPJ invalid"
        },
        {
          "id": "cnpj.isValid#[\"12.ABC.345/01DE-99\"]",
          "args": [
            "12.ABC.345/01DE-99"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when an alphanumeric CNPJ has an invalid check digit"
        },
        {
          "id": "cnpj.isValid#[\"Q0SLFMBD7VX400\",{\"version\":2}]",
          "args": [
            "Q0SLFMBD7VX400",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when an alphanumeric CNPJ has an invalid check digit"
        },
        {
          "id": "cnpj.isValid#[\"Q0SLFMBD7VX439\"]",
          "args": [
            "Q0SLFMBD7VX439"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when it has letters but no version option is given (defaults to numeric-only)"
        },
        {
          "id": "cnpj.isValid#[\"00000000000000\",{\"version\":2}]",
          "args": [
            "00000000000000",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when it is a reserved number under version 2, even though its raw checksum happens to be valid"
        },
        {
          "id": "cnpj.isValid#[\"AB.1C2.D3E/4F5G-3\"]",
          "args": [
            "AB.1C2.D3E/4F5G-3"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when an alphanumeric CNPJ is too short"
        },
        {
          "id": "cnpj.isValid#[\"AB.1C2.D3E/4F5G-356\"]",
          "args": [
            "AB.1C2.D3E/4F5G-356"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when an alphanumeric CNPJ is too long"
        },
        {
          "id": "cnpj.isValid#[\"!13723705000189\"]",
          "args": [
            "!13723705000189"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when there is garbage before the digits, since the numeric format is anchored at the start"
        },
        {
          "id": "cnpj.isValid#[\"13723705000189!\"]",
          "args": [
            "13723705000189!"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when there is garbage after the digits, since the numeric format is anchored at the end"
        },
        {
          "id": "cnpj.isValid#[\"!1Z000000000039\",{\"version\":2}]",
          "args": [
            "!1Z000000000039",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when there is garbage before an otherwise valid alphanumeric CNPJ, since the alphanumeric format is anchored at the start"
        },
        {
          "id": "cnpj.isValid#[\"1Z000000000039!\",{\"version\":2}]",
          "args": [
            "1Z000000000039!",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when there is garbage after an otherwise valid alphanumeric CNPJ, since the alphanumeric format is anchored at the end"
        },
        {
          "id": "cnpj.isValid#[\"13723705000189\"]",
          "args": [
            "13723705000189"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should return true when is a CNPJ valid without mask"
        },
        {
          "id": "cnpj.isValid#[\"60.391.947/0001-00\"]",
          "args": [
            "60.391.947/0001-00"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should return true when is a CNPJ valid with mask"
        },
        {
          "id": "cnpj.isValid#[\"11 222 333 0001 81\"]",
          "args": [
            "11 222 333 0001 81"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should return true when is a CNPJ valid with a whitespace mask"
        },
        {
          "id": "cnpj.isValid#[\" 13723705000189 \"]",
          "args": [
            " 13723705000189 "
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should return true when it has real leading and trailing whitespace (not just an internal mask)"
        },
        {
          "id": "cnpj.isValid#[\"1Z 000 000 0000 39\",{\"version\":2}]",
          "args": [
            "1Z 000 000 0000 39",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should return true when an alphanumeric CNPJ uses a whitespace separator at every group boundary"
        },
        {
          "id": "cnpj.isValid#[\"q0slfmbd7vx439\",{\"version\":2}]",
          "args": [
            "q0slfmbd7vx439",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should return true when is a lowercase alphanumeric CNPJ"
        },
        {
          "id": "cnpj.isValid#[\"1z000000000039\",{\"version\":2}]",
          "args": [
            "1z000000000039",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should return true when the lowercase letter is exactly the boundary z, which must still be uppercased and counted"
        },
        {
          "id": "cnpj.isValid#[\"15515147234255\"]",
          "args": [
            "15515147234255"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript docs example"
        },
        {
          "id": "cnpj.isValid#[\"q0slfmbd7vx439\"]",
          "args": [
            "q0slfmbd7vx439"
          ],
          "expect": {
            "returns": false
          },
          "note": "default version 1 rejects an alphanumeric CNPJ"
        }
      ]
    },
    {
      "id": "cnpj.parse",
      "level": "extended",
      "summary": "Removes the CNPJ formatting characters and returns the digits, or the letters and digits in upper case (version 2).",
      "description": "Removes CNPJ formatting and returns the normalized value, capped at 14 characters.\n\n- `options.version`: `1` (default) keeps digits only. `2` keeps letters and digits, upper-cased. Any other value is read as `1`.\n- 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).\n- Since July 2026 new CNPJs may be alphanumeric. The default `version: 1` drops their letters, so pass `version: 2` to keep them. A lower case letter is upper-cased first, since the official set is `A` to `Z`.",
      "params": [
        {
          "name": "value",
          "type": "string | number"
        },
        {
          "name": "options",
          "type": "ParseCnpjOptions",
          "optional": true
        }
      ],
      "returns": "string",
      "cases": [
        {
          "id": "cnpj.parse#masked",
          "args": [
            "46.843.485/0001-86"
          ],
          "expect": {
            "returns": "46843485000186"
          }
        },
        {
          "id": "cnpj.parse#unmasked",
          "args": [
            "46843485000186"
          ],
          "expect": {
            "returns": "46843485000186"
          }
        },
        {
          "id": "cnpj.parse#strips-non-digits",
          "args": [
            "46.?ABC843.485/0001-86abc"
          ],
          "expect": {
            "returns": "46843485000186"
          }
        },
        {
          "id": "cnpj.parse#empty",
          "args": [
            ""
          ],
          "expect": {
            "returns": ""
          }
        },
        {
          "id": "cnpj.parse#caps-length",
          "args": [
            "46843485000186123"
          ],
          "expect": {
            "returns": "46843485000186"
          },
          "note": "reference truncates to the 14 characters of the document; asserted by the reference (JS) unit tests"
        },
        {
          "id": "cnpj.parse#[\"10799163989271\"]",
          "args": [
            "10799163989271"
          ],
          "expect": {
            "returns": "10799163989271"
          },
          "note": "consensus of 3 libs (python, ruby, rust)"
        },
        {
          "id": "cnpj.parse#[\"10799163989272\"]",
          "args": [
            "10799163989272"
          ],
          "expect": {
            "returns": "10799163989272"
          },
          "note": "consensus of 3 libs (python, ruby, rust)"
        },
        {
          "id": "cnpj.parse#[\"00000000000000\"]",
          "args": [
            "00000000000000"
          ],
          "expect": {
            "returns": "00000000000000"
          },
          "note": "consensus of 3 libs (python, ruby, rust)"
        },
        {
          "id": "cnpj.parse#[\"64977017647333\"]",
          "args": [
            "64977017647333"
          ],
          "expect": {
            "returns": "64977017647333"
          },
          "note": "consensus of 3 libs (python, ruby, rust)"
        },
        {
          "id": "cnpj.parse#[\"64977017647334\"]",
          "args": [
            "64977017647334"
          ],
          "expect": {
            "returns": "64977017647334"
          },
          "note": "consensus of 3 libs (python, ruby, rust)"
        },
        {
          "id": "cnpj.parse#[\"62932200808587\"]",
          "args": [
            "62932200808587"
          ],
          "expect": {
            "returns": "62932200808587"
          },
          "note": "consensus of 3 libs (python, ruby, rust)"
        },
        {
          "id": "cnpj.parse#[\"62932200808588\"]",
          "args": [
            "62932200808588"
          ],
          "expect": {
            "returns": "62932200808588"
          },
          "note": "consensus of 3 libs (python, ruby, rust)"
        },
        {
          "id": "cnpj.parse#[\"10.799.163/9892-71\"]",
          "args": [
            "10.799.163/9892-71"
          ],
          "expect": {
            "returns": "10799163989271"
          },
          "note": "consensus of 3 libs (python, ruby, rust)"
        },
        {
          "id": "cnpj.parse#[\"64.977.017/6473-33\"]",
          "args": [
            "64.977.017/6473-33"
          ],
          "expect": {
            "returns": "64977017647333"
          },
          "note": "consensus of 3 libs (python, ruby, rust)"
        },
        {
          "id": "cnpj.parse#[\"62.932.200/8085-87\"]",
          "args": [
            "62.932.200/8085-87"
          ],
          "expect": {
            "returns": "62932200808587"
          },
          "note": "consensus of 3 libs (python, ruby, rust)"
        },
        {
          "id": "cnpj.parse#[\"Q0.SLF.MBD/7VX4-39\",{\"version\":2}]",
          "args": [
            "Q0.SLF.MBD/7VX4-39",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0SLFMBD7VX439"
          },
          "note": "JavaScript's own test: should keep alphanumeric characters for version 2"
        },
        {
          "id": "cnpj.parse#[\"Q0.SLF.MBD/7VX4-39ABC\",{\"version\":2}]",
          "args": [
            "Q0.SLF.MBD/7VX4-39ABC",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0SLFMBD7VX439"
          },
          "note": "JavaScript's own test: should ignore characters after the CNPJ length for version 2"
        },
        {
          "id": "cnpj.parse#[\"12.abc.345/01de-35\",{\"version\":2}]",
          "args": [
            "12.abc.345/01de-35",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "12ABC34501DE35"
          },
          "note": "JavaScript's own test: should upper-case lower case letters for version 2, the official set being A to Z"
        },
        {
          "id": "cnpj.parse#[\"q0slfmbd7vx439\",{\"version\":2}]",
          "args": [
            "q0slfmbd7vx439",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "Q0SLFMBD7VX439"
          },
          "note": "JavaScript's own test: should upper-case lower case letters for version 2, the official set being A to Z"
        },
        {
          "id": "cnpj.parse#[-11222333000181]",
          "args": [
            -11222333000181
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: when it is a negative, fractional or unsafe number; changed in 2.5.0 (#593): a number is read only when it is a non-negative safe integer"
        },
        {
          "id": "cnpj.parse#[-1]",
          "args": [
            -1
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: when it is a negative, fractional or unsafe number; changed in 2.5.0 (#593): a number is read only when it is a non-negative safe integer"
        },
        {
          "id": "cnpj.parse#[1.5]",
          "args": [
            1.5
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: when it is a negative, fractional or unsafe number; changed in 2.5.0 (#593): a number is read only when it is a non-negative safe integer"
        },
        {
          "id": "cnpj.parse#[9007199254740992]",
          "args": [
            9007199254740992
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: when it is a negative, fractional or unsafe number; changed in 2.5.0 (#593): a number is read only when it is a non-negative safe integer"
        },
        {
          "id": "cnpj.parse#[\"24.522.200/0001-74\"]",
          "args": [
            "24.522.200/0001-74"
          ],
          "expect": {
            "returns": "24522200000174"
          },
          "note": "JavaScript docs example"
        },
        {
          "id": "cnpj.parse#[\"12.OUT.345/0001-99\",{\"version\":2}]",
          "args": [
            "12.OUT.345/0001-99",
            {
              "version": 2
            }
          ],
          "expect": {
            "returns": "12OUT345000199"
          },
          "note": "JavaScript docs example"
        }
      ]
    }
  ]
}
