{
  "$schema": "../cases.schema.json",
  "format": 1,
  "domain": "bank",
  "title": {
    "en": "Banks",
    "pt-BR": "Bancos"
  },
  "functions": [
    {
      "id": "bank.getByCode",
      "level": "extended",
      "summary": "Looks up a Brazilian bank by its compensation code (COMPE).",
      "description": "Looks up a bank by its 3-digit COMPE code in the Banco Central do Brasil STR participants list.\n\n- Every character that is not a digit is removed from a string, as in 2.4.0. So `\"0-01\"`, `\"341/\"` and even `\"0x1\"` resolve. The remaining digits are left-padded with zeros to 3.\n- A number is read only when it is a safe non-negative integer, as the zero-padded 3-digit code. A negative or fractional number returns `null`.\n- The result carries the COMPE `code` (3 digits), the `ispb` (8 characters) and the `name`. It is a fresh copy.\n- Returns `null` when no bank has that code, when nothing is left after stripping, or when more than 3 digits are left.\n- The table is regenerated from the STR participants list of 25/09/2026.",
      "params": [
        {
          "name": "code",
          "type": "string | number"
        }
      ],
      "returns": "Bank?",
      "cases": [
        {
          "id": "bank.getByCode#[\"001\"]",
          "args": [
            "001"
          ],
          "expect": {
            "returns": {
              "code": "001",
              "ispb": "00000000",
              "name": "Banco do Brasil S.A."
            }
          }
        },
        {
          "id": "bank.getByCode#unpadded",
          "args": [
            "1"
          ],
          "expect": {
            "returns": {
              "code": "001",
              "ispb": "00000000",
              "name": "Banco do Brasil S.A."
            }
          }
        },
        {
          "id": "bank.getByCode#number",
          "args": [
            1
          ],
          "expect": {
            "returns": {
              "code": "001",
              "ispb": "00000000",
              "name": "Banco do Brasil S.A."
            }
          }
        },
        {
          "id": "bank.getByCode#[\"341\"]",
          "args": [
            "341"
          ],
          "expect": {
            "returns": {
              "code": "341",
              "ispb": "60701190",
              "name": "ITAÚ UNIBANCO S.A."
            }
          }
        },
        {
          "id": "bank.getByCode#nonexistent",
          "args": [
            "999"
          ],
          "expect": {
            "returns": null
          }
        },
        {
          "id": "bank.getByCode#[\"abc\"]",
          "args": [
            "abc"
          ],
          "expect": {
            "returns": null
          }
        },
        {
          "id": "bank.getByCode#empty",
          "args": [
            ""
          ],
          "expect": {
            "returns": null
          }
        },
        {
          "id": "bank.getByCode#[-1]",
          "args": [
            -1
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a negative or fractional number whose digits would otherwise match a bank"
        },
        {
          "id": "bank.getByCode#[0.01]",
          "args": [
            0.01
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a negative or fractional number whose digits would otherwise match a bank"
        },
        {
          "id": "bank.getByCode#[\"0-01\"]",
          "args": [
            "0-01"
          ],
          "expect": {
            "returns": {
              "code": "001",
              "ispb": "00000000",
              "name": "Banco do Brasil S.A."
            }
          },
          "note": "JavaScript's own test: should return the bank when the code has a mask"
        },
        {
          "id": "bank.getByCode#[\"00001\"]",
          "args": [
            "00001"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the code is longer than 3 digits"
        },
        {
          "id": "bank.getByCode#[\"341/\"]",
          "args": [
            "341/"
          ],
          "expect": {
            "returns": {
              "code": "341",
              "ispb": "60701190",
              "name": "ITAÚ UNIBANCO S.A."
            }
          },
          "note": "#596. JavaScript's own test: should strip any non-digit character of a string, as up to 2.4.0"
        },
        {
          "id": "bank.getByCode#[\"0x1\"]",
          "args": [
            "0x1"
          ],
          "expect": {
            "returns": {
              "code": "001",
              "ispb": "00000000",
              "name": "Banco do Brasil S.A."
            }
          },
          "note": "#596. JavaScript's own test: should strip any non-digit character of a string, as up to 2.4.0"
        },
        {
          "id": "bank.getByCode#[\" - \"]",
          "args": [
            " - "
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the code has no digits"
        },
        {
          "id": "bank.getByCode#[9007199254740992]",
          "args": [
            9007199254740992
          ],
          "expect": {
            "returns": null
          },
          "note": "#593 number rule: 2 ** 53 is not a safe integer"
        },
        {
          "id": "bank.getByCode#[\"516\"]",
          "args": [
            "516"
          ],
          "expect": {
            "returns": {
              "code": "516",
              "ispb": "36583700",
              "name": "PLACARPAY S.A. - SOCIEDADE DE CRÉDITO, FINANCIAMENTO E INVESTIMENTO"
            }
          },
          "note": "changed in 2.5.0 (#593): name from the STR participants list of 25/09/2026 (2.4.0: QISTA S.A. - CRÉDITO, FINANCIAMENTO E INVESTIMENTO)"
        },
        {
          "id": "bank.getByCode#[\"692\"]",
          "args": [
            "692"
          ],
          "expect": {
            "returns": {
              "code": "692",
              "ispb": "56198117",
              "name": "ZYDI SOCIEDADE DE CRÉDITO DIRETO S.A."
            }
          },
          "note": "changed in 2.5.0 (#593): name from the STR participants list of 25/09/2026 (2.4.0: SQUID SOCIEDADE DE CRÉDITO DIRETO S.A.)"
        }
      ]
    },
    {
      "id": "bank.getByIspb",
      "level": "extended",
      "summary": "Looks up a Brazilian bank by its ISPB (Identificador do Sistema de Pagamentos Brasileiro), which may be alphanumeric.",
      "description": "Looks up a bank by its 8-character ISPB (Identificador do Sistema de Pagamentos Brasileiro).\n\n- Resolução BCB 585/2026 (art. 2º III) made the ISPB 8 alphanumeric characters. Letters are kept and read without regard to case.\n- Every character that is neither a letter nor a digit is removed, so the CNPJ-root mask works: `\"00.000.000\"` finds Banco do Brasil.\n- A shorter value is left-padded with zeros (`0` is `00000000`). An empty value, or one with more than 8 characters left, returns `null`.\n- 2.4.0 removed letters too, so `\"0000000A\"` was read as `00000000` (Banco do Brasil). Now it returns `null`.\n- A number is read only when it is a safe non-negative integer. A negative or fractional number returns `null`.\n- The dataset only has institutions that also have a COMPE code. Any other ISPB returns `null`. The result is a fresh copy.",
      "params": [
        {
          "name": "value",
          "type": "string | number"
        }
      ],
      "returns": "Bank?",
      "cases": [
        {
          "id": "bank.getByIspb#[\"00000000\"]",
          "args": [
            "00000000"
          ],
          "expect": {
            "returns": {
              "code": "001",
              "ispb": "00000000",
              "name": "Banco do Brasil S.A."
            }
          }
        },
        {
          "id": "bank.getByIspb#[\"60701190\"]",
          "args": [
            "60701190"
          ],
          "expect": {
            "returns": {
              "code": "341",
              "ispb": "60701190",
              "name": "ITAÚ UNIBANCO S.A."
            }
          }
        },
        {
          "id": "bank.getByIspb#nonexistent",
          "args": [
            "99999999"
          ],
          "expect": {
            "returns": null
          }
        },
        {
          "id": "bank.getByIspb#[\"abc\"]",
          "args": [
            "abc"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the ispb has letters and fewer than 8 characters (padded to 00000ABC, which no bank has)"
        },
        {
          "id": "bank.getByIspb#empty",
          "args": [
            ""
          ],
          "expect": {
            "returns": null
          }
        },
        {
          "id": "bank.getByIspb#[-208]",
          "args": [
            -208
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a negative or fractional number whose digits would otherwise match a bank"
        },
        {
          "id": "bank.getByIspb#[2.08]",
          "args": [
            2.08
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null for a negative or fractional number whose digits would otherwise match a bank"
        },
        {
          "id": "bank.getByIspb#[\"0\"]",
          "args": [
            "0"
          ],
          "expect": {
            "returns": {
              "code": "001",
              "ispb": "00000000",
              "name": "Banco do Brasil S.A."
            }
          },
          "note": "JavaScript's own test: should return the bank when the ispb is a string without leading zeros"
        },
        {
          "id": "bank.getByIspb#[0]",
          "args": [
            0
          ],
          "expect": {
            "returns": {
              "code": "001",
              "ispb": "00000000",
              "name": "Banco do Brasil S.A."
            }
          },
          "note": "JavaScript's own test: should return the bank when the ispb is a number"
        },
        {
          "id": "bank.getByIspb#[\"0000-0000\"]",
          "args": [
            "0000-0000"
          ],
          "expect": {
            "returns": {
              "code": "001",
              "ispb": "00000000",
              "name": "Banco do Brasil S.A."
            }
          },
          "note": "JavaScript's own test: should return the bank when the ispb has a mask"
        },
        {
          "id": "bank.getByIspb#[\"0000000000\"]",
          "args": [
            "0000000000"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the ispb is longer than 8 digits"
        },
        {
          "id": "bank.getByIspb#[\"00.000.000\"]",
          "args": [
            "00.000.000"
          ],
          "expect": {
            "returns": {
              "code": "001",
              "ispb": "00000000",
              "name": "Banco do Brasil S.A."
            }
          },
          "note": "from the maintainer briefing, #596. JavaScript's own test: should drop every character that is neither a letter nor a digit, as up to 2.4.0"
        },
        {
          "id": "bank.getByIspb#[\"0000/0000\"]",
          "args": [
            "0000/0000"
          ],
          "expect": {
            "returns": {
              "code": "001",
              "ispb": "00000000",
              "name": "Banco do Brasil S.A."
            }
          },
          "note": "JavaScript's own test: should drop every character that is neither a letter nor a digit, as up to 2.4.0"
        },
        {
          "id": "bank.getByIspb#[\" 60.701.190 \"]",
          "args": [
            " 60.701.190 "
          ],
          "expect": {
            "returns": {
              "code": "341",
              "ispb": "60701190",
              "name": "ITAÚ UNIBANCO S.A."
            }
          },
          "note": "JavaScript's own test: should drop every character that is neither a letter nor a digit, as up to 2.4.0"
        },
        {
          "id": "bank.getByIspb#[\"0000000A\"]",
          "args": [
            "0000000A"
          ],
          "expect": {
            "returns": null
          },
          "note": "from the maintainer briefing, #596. changed in 2.5.0: a letter is part of the alphanumeric ISPB (Resolução BCB 585/2026), so it is no longer stripped; 2.4.0 read this as 00000000 (Banco do Brasil). JavaScript's own test: should return null when the ispb has a letter, instead of reading its digits as another ISPB"
        },
        {
          "id": "bank.getByIspb#[\"A0000000\"]",
          "args": [
            "A0000000"
          ],
          "expect": {
            "returns": null
          },
          "note": "changed in 2.5.0 (#596): 2.4.0 read this as 00000000. JavaScript's own test: should return null when the ispb has a letter, instead of reading its digits as another ISPB"
        },
        {
          "id": "bank.getByIspb#[\"a0000000\"]",
          "args": [
            "a0000000"
          ],
          "expect": {
            "returns": null
          },
          "note": "changed in 2.5.0 (#596): lower case is the same ISPB as A0000000, which no bank has. JavaScript's own test: should return null when the ispb has a letter, instead of reading its digits as another ISPB"
        },
        {
          "id": "bank.getByIspb#[\"1e0\"]",
          "args": [
            "1e0"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the ispb, stripped of anything but letters and digits, is no ISPB"
        },
        {
          "id": "bank.getByIspb#[\"ISPB 00000000\"]",
          "args": [
            "ISPB 00000000"
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the ispb, stripped of anything but letters and digits, is no ISPB"
        },
        {
          "id": "bank.getByIspb#[\" - \"]",
          "args": [
            " - "
          ],
          "expect": {
            "returns": null
          },
          "note": "JavaScript's own test: should return null when the ispb is only separators"
        },
        {
          "id": "bank.getByIspb#[\"060701190\"]",
          "args": [
            "060701190"
          ],
          "expect": {
            "returns": null
          },
          "note": "more than 8 characters after stripping (#596)"
        },
        {
          "id": "bank.getByIspb#[60701190]",
          "args": [
            60701190
          ],
          "expect": {
            "returns": {
              "code": "341",
              "ispb": "60701190",
              "name": "ITAÚ UNIBANCO S.A."
            }
          },
          "note": "a safe non-negative integer is read as the ISPB"
        },
        {
          "id": "bank.getByIspb#[9007199254740992]",
          "args": [
            9007199254740992
          ],
          "expect": {
            "returns": null
          },
          "note": "#593 number rule: 2 ** 53 is not a safe integer"
        }
      ]
    },
    {
      "id": "bank.list",
      "level": "extended",
      "summary": "Returns every Brazilian bank with a compensation code (COMPE) from the STR (Sistema de Transferência de Reservas) participants list that Banco Central do Brasil publishes.",
      "description": "Returns every bank with a COMPE code from the Banco Central do Brasil STR participants list.\n\n- Each call returns a fresh array of fresh objects, in a fixed table order, so mutating the result never affects the data or a later call.\n- Each entry carries the COMPE `code` (3 digits), the `ispb` (8 digits) and the `name`.\n- The table is regenerated from the STR participants list of 25/09/2026. Names follow that list (for example, 516 is now PLACARPAY and 692 is ZYDI).",
      "params": [],
      "returns": "Bank[]",
      "cases": []
    }
  ]
}
