{
  "$schema": "../cases.schema.json",
  "format": 1,
  "domain": "pixKey",
  "title": {
    "en": "Pix key",
    "pt-BR": "Chave Pix"
  },
  "functions": [
    {
      "id": "pixKey.getInfo",
      "level": "extended",
      "summary": "Identifies the type of a Pix key and returns the key in canonical form.",
      "description": "Identifies a Pix key and normalizes it to the canonical form the DICT expects inside a BR Code. Returns `null` when the value is not a valid Pix key.\n\n- The result has the key type (CPF, CNPJ, email, phone or EVP) and the canonical value: digits for a CPF or CNPJ (letters upper-cased), a lowercase email, an E.164 phone or a lowercase UUID.\n- Leading and trailing whitespace is ignored.\n- An 11-digit value valid as both CPF and mobile phone is a CPF, unless written as a phone (`+55` prefix or DDD in parentheses).\n- A CPF key is recognized by the way it is written: the bare 11 digits, or the groups 3-3-3-2 split by whitespace, `.`, `-` or `/`, alone or in a run, as `cpf.isValid` reads its mask. So `123.456.789-09`, `123/456/789/09` and `123 - 456.789 09` are the CPF key `12345678909`. Until 2.4.0 a `/` (or a run of separators) between the groups made it not a key. A separator outside those positions (`1234/56789/09`, `1.2.3.4.5.6.7.8.9.0.9`) is not a CPF.\n- A phone key holds only digits, spaces and the `+`, `-`, `(`, `)` and `.` of the usual masks, with or without the `+55`. Text around the value is not stripped: `abc123.456.789-09`, `CPF 123.456.789-09` and `tel: (11) 98765-4321` are not keys. A value with a valid CNPJ check digit is a CNPJ, even when it starts with `0055`. The E.164 value has at most 14 characters. The `+55` appears once, followed by the 11-digit national number, so a doubled country code (`+555511987654321`, `+55+5511987654321`, `0055+5511987654321`) is not a key, as in 2.4.0.\n- A CNPJ key is a valid CNPJ of 14 characters (digits, or letters for the alphanumeric CNPJ), with or without its mask, returned unmasked and upper-cased. A random EVP key is a UUID with its punctuation (8-4-4-4-12 hexadecimal digits), returned in lowercase. The version and variant digits of the UUID are not checked. A value that is not a string gives `null`.\n- Landlines are not Pix keys. A phone key follows `phone.isValidMobile`, so a first subscriber digit of 6 is rejected (2.4.0 accepted it).\n- An email key is lowercased and checked against the pattern of the DICT API 2.12.1 and its limit of 77 characters, not against `email.isValid`. The local part may carry any of ``.!#$'*+/=?^_`{|}~-``, with dots anywhere, and the domain may be a single label. Each domain label has letters, digits and hyphens, at most 63 characters. So `fulano@example`, `a@localhost` and `a{b}@example.com` are keys; 2.4.0 checked the key with `email.isValid` and rejected them.\n- The `&` is not allowed in an email key: DICT API 2.6.0 removed it from the pattern. `a&b@example.com` is not a key.\n- Returns `null` exactly when `pixKey.isValid` returns `false`.",
      "params": [
        {
          "name": "value",
          "type": "string"
        }
      ],
      "returns": "PixKeyInfo?",
      "cases": [
        {
          "id": "pixKey.getInfo#cpf",
          "args": [
            "123.456.789-09"
          ],
          "expect": {
            "returns": {
              "type": "cpf",
              "value": "12345678909"
            }
          }
        },
        {
          "id": "pixKey.getInfo#cnpj",
          "args": [
            "00.038.166/0001-05"
          ],
          "expect": {
            "returns": {
              "type": "cnpj",
              "value": "00038166000105"
            }
          }
        },
        {
          "id": "pixKey.getInfo#email",
          "args": [
            "fulano_da_silva.recebedor@example.com"
          ],
          "expect": {
            "returns": {
              "type": "email",
              "value": "fulano_da_silva.recebedor@example.com"
            }
          }
        },
        {
          "id": "pixKey.getInfo#phone",
          "args": [
            "+5561912345678"
          ],
          "expect": {
            "returns": {
              "type": "phone",
              "value": "+5561912345678"
            }
          }
        },
        {
          "id": "pixKey.getInfo#evp",
          "args": [
            "71c7d9be-4b85-4e43-9f1c-1f3b8b4e9a2d"
          ],
          "expect": {
            "returns": {
              "type": "evp",
              "value": "71c7d9be-4b85-4e43-9f1c-1f3b8b4e9a2d"
            }
          }
        },
        {
          "id": "pixKey.getInfo#invalid-cpf",
          "args": [
            "11257245286"
          ],
          "expect": {
            "returns": null
          }
        },
        {
          "id": "pixKey.getInfo#empty",
          "args": [
            ""
          ],
          "expect": {
            "returns": null
          }
        },
        {
          "id": "pixKey.getInfo#[\"   \"]",
          "args": [
            "   "
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is an empty or blank string"
        },
        {
          "id": "pixKey.getInfo#[\"11222333000182\"]",
          "args": [
            "11222333000182"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is an invalid CNPJ"
        },
        {
          "id": "pixKey.getInfo#[\"fulano@\"]",
          "args": [
            "fulano@"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is an invalid e-mail"
        },
        {
          "id": "pixKey.getInfo#[\"@example.com\"]",
          "args": [
            "@example.com"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is an invalid e-mail"
        },
        {
          "id": "pixKey.getInfo#[\"fulano@example\"]",
          "args": [
            "fulano@example"
          ],
          "expect": {
            "returns": {
              "type": "email",
              "value": "fulano@example"
            }
          },
          "note": "changed in 2.5.0 (#593): the DICT API email pattern accepts a single-label domain; 2.4.0 checked the key with isValidEmail and returned null"
        },
        {
          "id": "pixKey.getInfo#[\"71c7d9be4b854e439f1c1f3b8b4e9a2d\"]",
          "args": [
            "71c7d9be4b854e439f1c1f3b8b4e9a2d"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the random key is not a UUID"
        },
        {
          "id": "pixKey.getInfo#[\"71c7d9be-4b85-4e43-9f1c-1f3b8b4e9a2\"]",
          "args": [
            "71c7d9be-4b85-4e43-9f1c-1f3b8b4e9a2"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the random key is not a UUID"
        },
        {
          "id": "pixKey.getInfo#[\"71c7d9be-4b85-4e43-9f1c-1f3b8b4e9azz\"]",
          "args": [
            "71c7d9be-4b85-4e43-9f1c-1f3b8b4e9azz"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the random key is not a UUID"
        },
        {
          "id": "pixKey.getInfo#[\"(00) 98765-4321\"]",
          "args": [
            "(00) 98765-4321"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the phone has an invalid area code"
        },
        {
          "id": "pixKey.getInfo#[\"(11) 3000-0000\"]",
          "args": [
            "(11) 3000-0000"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the phone is a landline, since the manual registers a mobile number"
        },
        {
          "id": "pixKey.getInfo#[\"+551130000000\"]",
          "args": [
            "+551130000000"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the phone is a landline, since the manual registers a mobile number"
        },
        {
          "id": "pixKey.getInfo#[\"1130000000\"]",
          "args": [
            "1130000000"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the phone is a landline, since the manual registers a mobile number"
        },
        {
          "id": "pixKey.getInfo#[\"chave pix\"]",
          "args": [
            "chave pix"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is free text"
        },
        {
          "id": "pixKey.getInfo#[\"---\"]",
          "args": [
            "---"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is free text"
        },
        {
          "id": "pixKey.getInfo#[\"abc(11) 98765-4321xyz\"]",
          "args": [
            "abc(11) 98765-4321xyz"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when a phone number is buried in surrounding text"
        },
        {
          "id": "pixKey.getInfo#[\"tel: (11) 98765-4321\"]",
          "args": [
            "tel: (11) 98765-4321"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when a phone number is buried in surrounding text"
        },
        {
          "id": "pixKey.getInfo#[\"abc123.456.789-09\"]",
          "args": [
            "abc123.456.789-09"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when a CPF is buried in surrounding text"
        },
        {
          "id": "pixKey.getInfo#[\"CPF 123.456.789-09\"]",
          "args": [
            "CPF 123.456.789-09"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when a CPF is buried in surrounding text"
        },
        {
          "id": "pixKey.getInfo#[\"1.2.3.4.5.6.7.8.9.0.9\"]",
          "args": [
            "1.2.3.4.5.6.7.8.9.0.9"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when a CPF is written with separators outside the documented positions"
        },
        {
          "id": "pixKey.getInfo#[\"123/456/789/09\"]",
          "args": [
            "123/456/789/09"
          ],
          "expect": {
            "returns": {
              "type": "cpf",
              "value": "12345678909"
            }
          },
          "note": "changed in 2.5.0 (#615): the CPF mask characters (whitespace, . - /) split the groups, as cpf.isValid reads them. JavaScript's own test: should return a CPF when its groups are split by any of the mask characters isValidCpf reads"
        },
        {
          "id": "pixKey.getInfo#[\"40364478829\"]",
          "args": [
            "40364478829"
          ],
          "expect": {
            "returns": {
              "type": "cpf",
              "value": "40364478829"
            }
          },
          "note": "JavaScript's own test: should return a CPF when it is unmasked"
        },
        {
          "id": "pixKey.getInfo#[\"  40364478829  \"]",
          "args": [
            "  40364478829  "
          ],
          "expect": {
            "returns": {
              "type": "cpf",
              "value": "40364478829"
            }
          },
          "note": "JavaScript's own test: should return a CPF when surrounded by whitespace"
        },
        {
          "id": "pixKey.getInfo#[\"00038166000105\"]",
          "args": [
            "00038166000105"
          ],
          "expect": {
            "returns": {
              "type": "cnpj",
              "value": "00038166000105"
            }
          },
          "note": "JavaScript's own test: should return a CNPJ when it is unmasked"
        },
        {
          "id": "pixKey.getInfo#[\"12ABC34501DE35\"]",
          "args": [
            "12ABC34501DE35"
          ],
          "expect": {
            "returns": {
              "type": "cnpj",
              "value": "12ABC34501DE35"
            }
          },
          "note": "JavaScript's own test: should return a CNPJ when it is the alphanumeric format of the manual"
        },
        {
          "id": "pixKey.getInfo#[\"12.abc.345/01de-35\"]",
          "args": [
            "12.abc.345/01de-35"
          ],
          "expect": {
            "returns": {
              "type": "cnpj",
              "value": "12ABC34501DE35"
            }
          },
          "note": "JavaScript's own test: should return a CNPJ when it is the alphanumeric format of the manual"
        },
        {
          "id": "pixKey.getInfo#[\"00551760871813\"]",
          "args": [
            "00551760871813"
          ],
          "expect": {
            "returns": {
              "type": "cnpj",
              "value": "00551760871813"
            }
          },
          "note": "JavaScript's own test: should resolve the CNPJ and phone ambiguity should read a valid CNPJ as a CNPJ even when it starts with 0055"
        },
        {
          "id": "pixKey.getInfo#[\"00.551.760/8718-13\"]",
          "args": [
            "00.551.760/8718-13"
          ],
          "expect": {
            "returns": {
              "type": "cnpj",
              "value": "00551760871813"
            }
          },
          "note": "JavaScript's own test: should resolve the CNPJ and phone ambiguity should read a valid CNPJ as a CNPJ even when it starts with 0055"
        },
        {
          "id": "pixKey.getInfo#[\"005511987654321\"]",
          "args": [
            "005511987654321"
          ],
          "expect": {
            "returns": {
              "type": "phone",
              "value": "+5511987654321"
            }
          },
          "note": "JavaScript's own test: should resolve the CNPJ and phone ambiguity should still read a 0055 prefixed mobile number as a phone"
        },
        {
          "id": "pixKey.getInfo#[\"00551133334444\"]",
          "args": [
            "00551133334444"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should resolve the CNPJ and phone ambiguity should return null for a 0055 prefixed value that is neither a valid CNPJ nor a mobile number"
        },
        {
          "id": "pixKey.getInfo#[\"  Fulano@Example.COM \"]",
          "args": [
            "  Fulano@Example.COM "
          ],
          "expect": {
            "returns": {
              "type": "email",
              "value": "fulano@example.com"
            }
          },
          "note": "JavaScript's own test: should return an e-mail when it is uppercased or padded"
        },
        {
          "id": "pixKey.getInfo#[\"(11) 98765-4321\"]",
          "args": [
            "(11) 98765-4321"
          ],
          "expect": {
            "returns": {
              "type": "phone",
              "value": "+5511987654321"
            }
          },
          "note": "JavaScript's own test: should return a phone when it is masked"
        },
        {
          "id": "pixKey.getInfo#[\"11987654321\"]",
          "args": [
            "11987654321"
          ],
          "expect": {
            "returns": {
              "type": "phone",
              "value": "+5511987654321"
            }
          },
          "note": "JavaScript's own test: should return a phone when it is bare"
        },
        {
          "id": "pixKey.getInfo#[\"+55 11 98765-4321\"]",
          "args": [
            "+55 11 98765-4321"
          ],
          "expect": {
            "returns": {
              "type": "phone",
              "value": "+5511987654321"
            }
          },
          "note": "JavaScript's own test: should return a phone when it carries the country code in every accepted form"
        },
        {
          "id": "pixKey.getInfo#[\"5511987654321\"]",
          "args": [
            "5511987654321"
          ],
          "expect": {
            "returns": {
              "type": "phone",
              "value": "+5511987654321"
            }
          },
          "note": "JavaScript's own test: should return a phone when it carries the country code in every accepted form"
        },
        {
          "id": "pixKey.getInfo#[\"71C7D9BE-4B85-4E43-9F1C-1F3B8B4E9A2D\"]",
          "args": [
            "71C7D9BE-4B85-4E43-9F1C-1F3B8B4E9A2D"
          ],
          "expect": {
            "returns": {
              "type": "evp",
              "value": "71c7d9be-4b85-4e43-9f1c-1f3b8b4e9a2d"
            }
          },
          "note": "JavaScript's own test: should return a random key when it is uppercased, lowercasing it"
        },
        {
          "id": "pixKey.getInfo#[\"123e4567-e12b-12d1-a456-426655440000\"]",
          "args": [
            "123e4567-e12b-12d1-a456-426655440000"
          ],
          "expect": {
            "returns": {
              "type": "evp",
              "value": "123e4567-e12b-12d1-a456-426655440000"
            }
          },
          "note": "JavaScript's own test: should return a random key when it is the example of the manual, whose version nibble is not 4"
        },
        {
          "id": "pixKey.getInfo#[\"51998259765\"]",
          "args": [
            "51998259765"
          ],
          "expect": {
            "returns": {
              "type": "cpf",
              "value": "51998259765"
            }
          },
          "note": "JavaScript's own test: should resolve the CPF and phone ambiguity preferring the CPF when the value is valid as both"
        },
        {
          "id": "pixKey.getInfo#[\"519.982.597-65\"]",
          "args": [
            "519.982.597-65"
          ],
          "expect": {
            "returns": {
              "type": "cpf",
              "value": "51998259765"
            }
          },
          "note": "JavaScript's own test: should resolve the CPF and phone ambiguity keeping the CPF when it is written with its own mask"
        },
        {
          "id": "pixKey.getInfo#[\"a&b@example.com\"]",
          "args": [
            "a&b@example.com"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test and docs example: the & was removed from the DICT API email pattern in version 2.6.0 (DICT API 2.12.1)"
        },
        {
          "id": "pixKey.getInfo#[\"Fulano@Example\"]",
          "args": [
            "Fulano@Example"
          ],
          "expect": {
            "returns": {
              "type": "email",
              "value": "fulano@example"
            }
          },
          "note": "JavaScript's own test: when it is the single label domain isValidEmail rejects, lowercased"
        },
        {
          "id": "pixKey.getInfo#[\"a@localhost\"]",
          "args": [
            "a@localhost"
          ],
          "expect": {
            "returns": {
              "type": "email",
              "value": "a@localhost"
            }
          },
          "note": "JavaScript's own test: should return an e-mail when it only matches the DICT pattern, not isValidEmail (changed in 2.5.0, #593: 2.4.0 returned null)"
        },
        {
          "id": "pixKey.getInfo#[\"a{b}@example.com\"]",
          "args": [
            "a{b}@example.com"
          ],
          "expect": {
            "returns": {
              "type": "email",
              "value": "a{b}@example.com"
            }
          },
          "note": "JavaScript's own test: should return an e-mail when it only matches the DICT pattern, not isValidEmail (changed in 2.5.0, #593: 2.4.0 returned null)"
        },
        {
          "id": "pixKey.getInfo#[\".ab@example.com\"]",
          "args": [
            ".ab@example.com"
          ],
          "expect": {
            "returns": {
              "type": "email",
              "value": ".ab@example.com"
            }
          },
          "note": "JavaScript's own test: should return an e-mail when it only matches the DICT pattern, not isValidEmail (changed in 2.5.0, #593: 2.4.0 returned null)"
        },
        {
          "id": "pixKey.getInfo#[\"a..b@example.com\"]",
          "args": [
            "a..b@example.com"
          ],
          "expect": {
            "returns": {
              "type": "email",
              "value": "a..b@example.com"
            }
          },
          "note": "JavaScript's own test: should return an e-mail when it only matches the DICT pattern, not isValidEmail (changed in 2.5.0, #593: 2.4.0 returned null)"
        },
        {
          "id": "pixKey.getInfo#[\"a@example.123\"]",
          "args": [
            "a@example.123"
          ],
          "expect": {
            "returns": {
              "type": "email",
              "value": "a@example.123"
            }
          },
          "note": "JavaScript's own test: should return an e-mail when it only matches the DICT pattern, not isValidEmail (changed in 2.5.0, #593: 2.4.0 returned null)"
        },
        {
          "id": "pixKey.getInfo#[\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@example.com\"]",
          "args": [
            "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@example.com"
          ],
          "expect": {
            "returns": {
              "type": "email",
              "value": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@example.com"
            }
          },
          "note": "JavaScript's own test: when it is exactly 77 characters long"
        },
        {
          "id": "pixKey.getInfo#[\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@example.com\"]",
          "args": [
            "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@example.com"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: when the e-mail is longer than 77 characters"
        },
        {
          "id": "pixKey.getInfo#[\"a@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.com\"]",
          "args": [
            "a@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.com"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: when a domain label is longer than the 63 characters of the DICT pattern"
        },
        {
          "id": "pixKey.getInfo#[\"fulano@example.com.\"]",
          "args": [
            "fulano@example.com."
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is an invalid e-mail"
        },
        {
          "id": "pixKey.getInfo#[\"fulano@exa_mple.com\"]",
          "args": [
            "fulano@exa_mple.com"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is an invalid e-mail"
        },
        {
          "id": "pixKey.getInfo#[\"ful%ano@example.com\"]",
          "args": [
            "ful%ano@example.com"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is an invalid e-mail"
        },
        {
          "id": "pixKey.getInfo#[\"\\\"fulano\\\"@example.com\"]",
          "args": [
            "\"fulano\"@example.com"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when it is an invalid e-mail"
        },
        {
          "id": "pixKey.getInfo#[\"+555511987654321\"]",
          "args": [
            "+555511987654321"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: when the phone repeats the country code"
        },
        {
          "id": "pixKey.getInfo#[\"+55+5511987654321\"]",
          "args": [
            "+55+5511987654321"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: when the phone repeats the country code"
        },
        {
          "id": "pixKey.getInfo#[\"0055+5511987654321\"]",
          "args": [
            "0055+5511987654321"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: when the phone repeats the country code"
        },
        {
          "id": "pixKey.getInfo#[\"+550055 11 98765-4321\"]",
          "args": [
            "+550055 11 98765-4321"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: when the phone repeats the country code"
        },
        {
          "id": "pixKey.getInfo#[\"+5511612345678\"]",
          "args": [
            "+5511612345678"
          ],
          "expect": {
            "returns": null
          },
          "note": "changed in 2.5.0 (#593): a first subscriber digit of 6 is not a mobile (Resolução Anatel nº 749/2022, art. 12). 2.4.0 returned a phone key"
        },
        {
          "id": "pixKey.getInfo#[\"123 - 456.789 09\"]",
          "args": [
            "123 - 456.789 09"
          ],
          "expect": {
            "returns": {
              "type": "cpf",
              "value": "12345678909"
            }
          },
          "note": "JavaScript's own test: should return a CPF when its groups are split by any of the mask characters isValidCpf reads"
        },
        {
          "id": "pixKey.getInfo#[\"1234/56789/09\"]",
          "args": [
            "1234/56789/09"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: when a CPF is written with separators outside the documented positions"
        },
        {
          "id": "pixKey.getInfo#[null]",
          "args": [
            null
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: when it is null"
        },
        {
          "id": "pixKey.getInfo#[\"Fulano@Example.COM \"]",
          "args": [
            "Fulano@Example.COM "
          ],
          "expect": {
            "returns": {
              "type": "email",
              "value": "fulano@example.com"
            }
          },
          "note": "JavaScript docs example"
        },
        {
          "id": "pixKey.getInfo#[\"+5551998259765\"]",
          "args": [
            "+5551998259765"
          ],
          "expect": {
            "returns": {
              "type": "phone",
              "value": "+5551998259765"
            }
          },
          "note": "JavaScript docs example: a +55 prefix reads the value as a phone, not a CPF"
        },
        {
          "id": "pixKey.getInfo#[\"(51) 99825-9765\"]",
          "args": [
            "(51) 99825-9765"
          ],
          "expect": {
            "returns": {
              "type": "phone",
              "value": "+5551998259765"
            }
          },
          "note": "JavaScript's own test: preferring the phone when the DDD is written between parentheses"
        }
      ]
    },
    {
      "id": "pixKey.isValid",
      "level": "extended",
      "summary": "Validates a Pix key against the DICT key formats.",
      "description": "Checks whether a value is a valid Pix key: a CPF, a CNPJ, an email, a Brazilian mobile phone or a random EVP key, per the DICT key formats.\n\n- Same recognition rules as `pixKey.getInfo`.\n- `options` can restrict the accepted key types. An empty list rejects everything.\n- `options.accept` is a list of the key types that count as valid (`cpf`, `cnpj`, `email`, `phone`, `evp`). When it is missing, or not a list, every type is accepted. A value that is not a string is not a key.",
      "params": [
        {
          "name": "value",
          "type": "string"
        },
        {
          "name": "options",
          "type": "IsValidPixKeyOptions",
          "optional": true
        }
      ],
      "returns": "boolean",
      "cases": [
        {
          "id": "pixKey.isValid#cpf",
          "args": [
            "123.456.789-09"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript docs example"
        },
        {
          "id": "pixKey.isValid#cnpj",
          "args": [
            "00.038.166/0001-05"
          ],
          "expect": {
            "returns": true
          }
        },
        {
          "id": "pixKey.isValid#email",
          "args": [
            "fulano_da_silva.recebedor@example.com"
          ],
          "expect": {
            "returns": true
          }
        },
        {
          "id": "pixKey.isValid#phone",
          "args": [
            "+5561912345678"
          ],
          "expect": {
            "returns": true
          }
        },
        {
          "id": "pixKey.isValid#evp",
          "args": [
            "71c7d9be-4b85-4e43-9f1c-1f3b8b4e9a2d"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript docs example"
        },
        {
          "id": "pixKey.isValid#invalid-cpf",
          "args": [
            "11257245286"
          ],
          "expect": {
            "returns": false
          }
        },
        {
          "id": "pixKey.isValid#email-without-tld",
          "args": [
            "fulano@example"
          ],
          "expect": {
            "returns": true
          },
          "note": "changed in 2.5.0 (#593): the DICT API email pattern accepts a single-label domain; 2.4.0 checked the key with isValidEmail and returned false"
        },
        {
          "id": "pixKey.isValid#landline",
          "args": [
            "1130000000"
          ],
          "expect": {
            "returns": false
          }
        },
        {
          "id": "pixKey.isValid#empty",
          "args": [
            ""
          ],
          "expect": {
            "returns": false
          }
        },
        {
          "id": "pixKey.isValid#[\"   \"]",
          "args": [
            "   "
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when it is an empty or blank string"
        },
        {
          "id": "pixKey.isValid#[\"(11) 3000-0000\"]",
          "args": [
            "(11) 3000-0000"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when the phone is a landline, since the manual registers a mobile number"
        },
        {
          "id": "pixKey.isValid#[\"chave pix\"]",
          "args": [
            "chave pix"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should return false when it is not a key of any accepted kind"
        },
        {
          "id": "pixKey.isValid#[\"40364478829\"]",
          "args": [
            "40364478829"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should return true for a CPF"
        },
        {
          "id": "pixKey.isValid#[\"12ABC34501DE35\"]",
          "args": [
            "12ABC34501DE35"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should return true for a CNPJ"
        },
        {
          "id": "pixKey.isValid#[\"(11) 98765-4321\"]",
          "args": [
            "(11) 98765-4321"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should return true for a mobile phone"
        },
        {
          "id": "pixKey.isValid#[\"123e4567-e12b-12d1-a456-426655440000\"]",
          "args": [
            "123e4567-e12b-12d1-a456-426655440000"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should return true for a random key"
        },
        {
          "id": "pixKey.isValid#[\"123.456.789-09\",{\"accept\":[\"cpf\"]}]",
          "args": [
            "123.456.789-09",
            {
              "accept": [
                "cpf"
              ]
            }
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should honour options.accept accepting only the listed kinds"
        },
        {
          "id": "pixKey.isValid#[\"123.456.789-09\",{\"accept\":[\"email\",\"evp\"]}]",
          "args": [
            "123.456.789-09",
            {
              "accept": [
                "email",
                "evp"
              ]
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should honour options.accept accepting only the listed kinds"
        },
        {
          "id": "pixKey.isValid#[\"fulano@example.com\",{\"accept\":[\"email\",\"evp\"]}]",
          "args": [
            "fulano@example.com",
            {
              "accept": [
                "email",
                "evp"
              ]
            }
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should honour options.accept accepting only the listed kinds"
        },
        {
          "id": "pixKey.isValid#[\"+5511987654321\",{\"accept\":[\"phone\"]}]",
          "args": [
            "+5511987654321",
            {
              "accept": [
                "phone"
              ]
            }
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should honour options.accept accepting only the listed kinds"
        },
        {
          "id": "pixKey.isValid#[\"00038166000105\",{\"accept\":[\"cnpj\"]}]",
          "args": [
            "00038166000105",
            {
              "accept": [
                "cnpj"
              ]
            }
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should honour options.accept accepting only the listed kinds"
        },
        {
          "id": "pixKey.isValid#[\"123.456.789-09\",{\"accept\":[]}]",
          "args": [
            "123.456.789-09",
            {
              "accept": []
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: should honour options.accept accepting nothing for an empty list"
        },
        {
          "id": "pixKey.isValid#[\"123.456.789-09\",{}]",
          "args": [
            "123.456.789-09",
            {}
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should honour options.accept accepting every kind when the option is absent or not a list"
        },
        {
          "id": "pixKey.isValid#[\"a&b@example.com\"]",
          "args": [
            "a&b@example.com"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test and docs example: the & was removed from the DICT API email pattern in version 2.6.0"
        },
        {
          "id": "pixKey.isValid#[\"a{b}@example.com\"]",
          "args": [
            "a{b}@example.com"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: for an e-mail that only matches the DICT pattern, not isValidEmail (changed in 2.5.0, #593)"
        },
        {
          "id": "pixKey.isValid#[\"a@localhost\"]",
          "args": [
            "a@localhost"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: for an e-mail that only matches the DICT pattern, not isValidEmail (changed in 2.5.0, #593)"
        },
        {
          "id": "pixKey.isValid#[\"fulano@\"]",
          "args": [
            "fulano@"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: when it is not a key of any accepted kind"
        },
        {
          "id": "pixKey.isValid#[\"+555511987654321\"]",
          "args": [
            "+555511987654321"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: when the phone repeats the country code"
        },
        {
          "id": "pixKey.isValid#[\"+55+55 11 98765-4321\"]",
          "args": [
            "+55+55 11 98765-4321"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: when the phone repeats the country code"
        },
        {
          "id": "pixKey.isValid#[\"00555511987654321\"]",
          "args": [
            "00555511987654321"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: when the phone repeats the country code"
        },
        {
          "id": "pixKey.isValid#[\"+5511612345678\"]",
          "args": [
            "+5511612345678"
          ],
          "expect": {
            "returns": false
          },
          "note": "changed in 2.5.0 (#593): a first subscriber digit of 6 is not a mobile. 2.4.0 returned true"
        },
        {
          "id": "pixKey.isValid#[\"a{b}@example.com\",{\"accept\":[\"evp\",\"cpf\"]}]",
          "args": [
            "a{b}@example.com",
            {
              "accept": [
                "evp",
                "cpf"
              ]
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "options.accept restricts the key types"
        },
        {
          "id": "pixKey.isValid#[\"123/456/789/09\"]",
          "args": [
            "123/456/789/09"
          ],
          "expect": {
            "returns": true
          },
          "note": "changed in 2.5.0 (#615): the CPF mask characters split the groups, as cpf.isValid reads them"
        },
        {
          "id": "pixKey.isValid#[\"123 - 456.789 09\"]",
          "args": [
            "123 - 456.789 09"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: should return a CPF when its groups are split by any of the mask characters isValidCpf reads"
        },
        {
          "id": "pixKey.isValid#[\"1234/56789/09\"]",
          "args": [
            "1234/56789/09"
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: when a CPF is written with separators outside the documented positions"
        },
        {
          "id": "pixKey.isValid#[\"fulano@example.com\"]",
          "args": [
            "fulano@example.com"
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript docs example"
        },
        {
          "id": "pixKey.isValid#[null]",
          "args": [
            null
          ],
          "expect": {
            "returns": false
          },
          "note": "JavaScript's own test: when it is null"
        },
        {
          "id": "pixKey.isValid#[\"123.456.789-09\",null]",
          "args": [
            "123.456.789-09",
            null
          ],
          "expect": {
            "returns": true
          },
          "note": "JavaScript's own test: accepting every kind when the option is absent or not a list"
        },
        {
          "id": "pixKey.isValid#[\"fulano@example.com\",{\"accept\":[\"cpf\"]}]",
          "args": [
            "fulano@example.com",
            {
              "accept": [
                "cpf"
              ]
            }
          ],
          "expect": {
            "returns": false
          },
          "note": "a key of a type outside options.accept is not valid"
        }
      ]
    }
  ]
}
