### IBANTools - Installation and Basic Usage Source: https://github.com/simplify/ibantools/blob/master/README.md This snippet covers the installation of IBANTools via npm and demonstrates basic usage for IBAN and BIC validation in a Node.js environment. ```APIDOC ## IBANTools Installation and Usage ### Description This section details how to install the IBANTools library and provides basic examples for validating IBAN and BIC numbers using Node.js. ### Installation ```bash npm install ibantools ``` ### Usage Example (Node.js) ```javascript const ibantools = require('ibantools'); // Format IBAN const formattedIBAN = ibantools.electronicFormatIBAN('NL91 ABNA 0417 1643 00'); // 'NL91ABNA0517164300' // Validate IBAN const isValidIBAN = ibantools.isValidIBAN(formattedIBAN); console.log(`Is IBAN valid? ${isValidIBAN}`); // Validate IBAN with error codes const validationResult = ibantools.validateIBAN('NL91ABNA0517164300'); console.log(validationResult); // Example output: { valid: false, errorCodes: ['iban.ValidationErrorsIBAN.WrongIBANChecksum'] } // Validate BIC const isValidBIC = ibantools.isValidBIC('ABNANL2A'); console.log(`Is BIC valid? ${isValidBIC}`); ``` ``` -------------------------------- ### Install IBANTools via Package Managers Source: https://github.com/simplify/ibantools/blob/master/docs/index.html Instructions for adding the IBANTools library to your project using npm or Bower. ```bash npm install ibantools ``` ```bash bower install ibantools ``` -------------------------------- ### IBANTools - Extending Country BBAN Validation Source: https://github.com/simplify/ibantools/blob/master/README.md Illustrates how to extend IBANTools with custom country-specific BBAN validation rules, using a German IBAN example. ```APIDOC ## IBANTools Extension ### Description This section explains how to extend IBANTools with custom national BBAN validation logic. It provides an example for German IBAN validation using an external library. ### Extending German IBAN Validation ```javascript const ibantools = require('ibantools'); const ibantoolsGermany = require("ibantools-germany"); // Set custom BBAN validation for Germany ibantools.setCountryBBANValidation("DE", ibantoolsGermany.isValidBBAN); // Now, IBANTools will use the German-specific validation for German IBANs. // Example: // const germanIBAN = 'DE89370400440532013000'; // Example German IBAN // console.log(ibantools.isValidIBAN(germanIBAN)); // Will use the extended validation ``` ``` -------------------------------- ### Format IBAN with default and custom separators Source: https://github.com/simplify/ibantools/blob/master/docs/functions/friendlyFormatIBAN.html Demonstrates how to use friendlyFormatIBAN to format an IBAN string. The first example uses the default space separator, while the second example uses a custom hyphen separator. ```typescript ibantools.friendlyFormatIBAN("NL91ABNA0417164300"); // returns "NL91 ABNA 0417 1643 00" ibantools.friendlyFormatIBAN("NL91ABNA0417164300", "-"); // returns "NL91-ABNA-0417-1643-00" ``` -------------------------------- ### Extending IBANTools with Custom Country BBAN Validation Source: https://github.com/simplify/ibantools/blob/master/README.md Shows how to extend IBANTools with custom national BBAN validation rules, using the example of German IBAN validation by integrating IBANTools-Germany. ```javascript const ibantools = require('ibantools'); const ibantoolsGermany = require("ibantools-germany"); ibantools.setCountryBBANValidation("DE", ibantoolsGermany.isValidBBAN); ``` -------------------------------- ### GET /countrySpecs Source: https://github.com/simplify/ibantools/blob/master/docs/variables/countrySpecs.html Retrieves the internal country specification mapping used for IBAN validation and formatting. ```APIDOC ## GET /countrySpecs ### Description Retrieves the internal configuration object containing country-specific IBAN rules, including length, structure, and checksum requirements. ### Method GET ### Endpoint /countrySpecs ### Parameters None ### Request Example GET /countrySpecs ### Response #### Success Response (200) - **countrySpecs** (CountryMapInternal) - An object mapping country codes to their respective validation specifications. #### Response Example { "DE": { "length": 22, "pattern": "DE\\d{20}" }, "GB": { "length": 22, "pattern": "GB\\d{2}[A-Z]{4}\\d{14}" } } ``` -------------------------------- ### IBANTools - Browser Usage (AMD) Source: https://github.com/simplify/ibantools/blob/master/README.md Demonstrates how to use IBANTools in a browser environment using AMD (Asynchronous Module Definition) with RequireJS. ```APIDOC ## IBANTools Browser Usage (AMD) ### Description This snippet shows how to integrate and use the IBANTools library in a web browser using the AMD module format with RequireJS. ### Usage Example (Browser with RequireJS) ```javascript require(["ibantools"], function(ibantools) { console.log(ibantools.isValidIBAN('NL91 ABNA 0417 1643 00')); console.log(ibantools.isValidBIC('ABNANL2A')); }); ``` ``` -------------------------------- ### Theme Setting and Page Display Logic Source: https://github.com/simplify/ibantools/blob/master/docs/functions/validateBIC.html This code snippet handles the initialization of the application's theme based on local storage and controls the initial display of the page. It sets the theme and then shows the page after a short delay or when the app is ready. ```javascript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => app ? app.showPage() : document.body.style.removeProperty("display"), 500); ``` -------------------------------- ### Initialize Theme and Display App - JavaScript Source: https://github.com/simplify/ibantools/blob/master/docs/interfaces/CountrySpec.html This JavaScript code snippet initializes the theme from local storage, hides the body content, and then displays the application or removes the display property after a short delay. It's used for controlling the initial rendering and theme of the web application. ```javascript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Validate IBAN and BIC in Node.js Source: https://github.com/simplify/ibantools/blob/master/docs/index.html Demonstrates how to import the library using CommonJS, format an IBAN, validate its structure, and check a BIC code. ```javascript const ibantools = require('ibantools'); const iban = electronicFormatIBAN('NL91 ABNA 0417 1643 00'); ibantools.isValidIBAN(iban); ibantools.validateIBAN('NL91ABNA0517164300'); ibantools.isValidBIC('ABNANL2A'); ``` -------------------------------- ### Browser AMD RequireJS IBAN and BIC Validation Source: https://github.com/simplify/ibantools/blob/master/README.md Illustrates how to integrate and use the ibantools library in a browser environment using AMD and RequireJS for IBAN and BIC validation. ```javascript require(["ibantools"], function(ibantools) { console.log(ibantools.isValidIBAN('NL91 ABNA 0417 1643 00')); console.log(ibantools.isValidBIC('ABNANL2A')); }); ``` -------------------------------- ### Node.js CommonJS IBAN and BIC Validation Source: https://github.com/simplify/ibantools/blob/master/README.md Demonstrates how to use the ibantools library in a Node.js CommonJS environment to validate IBAN and BIC formats. It shows how to format an IBAN, check its validity, and retrieve validation error codes. ```javascript const ibantools = require('ibantools'); const iban = ibantools.electronicFormatIBAN('NL91 ABNA 0417 1643 00'); // 'NL91ABNA0517164300' ibantools.isValidIBAN(iban); // If you want to know reason why IBAN is invalid ibantools.validateIBAN('NL91ABNA0517164300'); // Returns { valid: false, errorCodes: [iban.ValidationErrorsIBAN.WrongIBANChecksum] } // Validate BIC ibantools.isValidBIC('ABNANL2A'); ``` -------------------------------- ### Constructing an IBAN using composeIBAN Source: https://github.com/simplify/ibantools/blob/master/docs/functions/composeIBAN.html This snippet demonstrates how to use the composeIBAN function to generate an IBAN string. It requires a parameter object with countryCode and bban properties. ```typescript import { composeIBAN } from "ibantools"; // Returns NL91ABNA0417164300 const iban = composeIBAN({ countryCode: "NL", bban: "ABNA0417164300" }); ``` -------------------------------- ### Validate IBAN with IBANTools Source: https://github.com/simplify/ibantools/blob/master/docs/functions/validateIBAN.html Demonstrates how to use the validateIBAN function to check the validity of an IBAN string. It shows both standard validation and validation with custom options like disabling QR-IBAN support. ```javascript ibantools.validateIBAN("NL91ABNA0417164300"); ibantools.validateIBAN('CH4431999123000889012'); ibantools.validateIBAN('CH4431999123000889012', { allowQRIBAN: false }); ``` -------------------------------- ### Configure Custom BBAN Validation Source: https://context7.com/simplify/ibantools/llms.txt Shows how to extend the library's validation capabilities by defining custom national BBAN validation logic. ```javascript const ibantools = require('ibantools'); ibantools.setCountryBBANValidation('XX', (bban) => { return /^[0-9]{10}$/.test(bban); }); ``` -------------------------------- ### Compose IBAN from Country Code and BBAN - JavaScript Source: https://context7.com/simplify/ibantools/llms.txt Constructs a complete IBAN string by combining a country code and a Basic Bank Account Number (BBAN). It automatically calculates the correct IBAN checksum. Returns the formatted IBAN string if successful, or null if the provided country code or BBAN is invalid. Input is expected as an object with 'countryCode' and 'bban' properties. ```javascript const ibantools = require('ibantools'); // Compose Dutch IBAN const iban1 = ibantools.composeIBAN({ countryCode: "NL", bban: "ABNA0417164300" }); console.log(iban1); // "NL91ABNA0417164300" // Compose German IBAN const iban2 = ibantools.composeIBAN({ countryCode: "DE", bban: "370400440532013000" }); console.log(iban2); // "DE89370400440532013000" // Compose French IBAN const iban3 = ibantools.composeIBAN({ countryCode: "FR", bban: "20041010050500013M02606" }); console.log(iban3); // "FR7620041010050500013M02606" // Invalid BBAN returns null const iban4 = ibantools.composeIBAN({ countryCode: "NL", bban: "INVALID" }); console.log(iban4); // null // Missing country code returns null const iban5 = ibantools.composeIBAN({ bban: "ABNA0417164300" }); console.log(iban5); // null ``` -------------------------------- ### composeIBAN Function Source: https://github.com/simplify/ibantools/blob/master/docs/functions/composeIBAN.html The composeIBAN function takes parameters to construct a valid IBAN string. ```APIDOC ## POST /simplify/ibantools/composeIBAN ### Description Constructs an IBAN string based on the provided country code and BBAN. ### Method POST ### Endpoint /simplify/ibantools/composeIBAN ### Parameters #### Request Body - **params** (object) - Required - An object containing the parameters for composing the IBAN. - **countryCode** (string) - Required - The two-letter ISO country code. - **bban** (string) - Required - The Basic Bank Account Number. ### Request Example ```json { "params": { "countryCode": "NL", "bban": "ABNA0417164300" } } ``` ### Response #### Success Response (200) - **iban** (string) - The generated IBAN string. #### Response Example ```json { "iban": "NL91ABNA0417164300" } ``` ``` -------------------------------- ### Validate IBAN and BIC in JavaScript Source: https://context7.com/simplify/ibantools/llms.txt Demonstrates how to perform basic boolean validation for IBAN and BIC codes using the library. This is suitable for quick checks in form submission handlers. ```javascript const ibantools = require('ibantools'); const isValid = ibantools.isValidIBAN('DE12345678901234567890'); const isBicValid = ibantools.isValidBIC('ABCDEFF1XXX'); console.log(isValid, isBicValid); ``` ```typescript import * as ibantools from 'ibantools'; const isValid: boolean = ibantools.isValidIBAN('DE12345678901234567890'); const isBicValid: boolean = ibantools.isValidBIC('ABCDEFF1XXX'); ``` -------------------------------- ### Retrieve Country Specifications Source: https://context7.com/simplify/ibantools/llms.txt Fetches a comprehensive object containing validation rules for all supported countries, including expected character lengths, BBAN regex patterns, and SEPA status. ```javascript const ibantools = require('ibantools'); const specs = ibantools.getCountrySpecifications(); console.log(specs["NL"]); console.log(specs["DE"]); const country = "NL"; const countrySpec = specs[country]; const pattern = country + "[0-9]{2}" + countrySpec.bban_regexp.slice(1, -1); ``` -------------------------------- ### Format IBAN for Display Source: https://context7.com/simplify/ibantools/llms.txt Formats an IBAN string into a human-readable format by inserting a separator every four characters. The separator defaults to a space but can be customized. ```javascript const ibantools = require('ibantools'); console.log(ibantools.friendlyFormatIBAN("NL91ABNA0417164300", "-")); ``` -------------------------------- ### ValidateIBANOptions Interface Source: https://github.com/simplify/ibantools/blob/master/docs/interfaces/ValidateIBANOptions.html Configuration interface for customizing IBAN validation logic. ```APIDOC ## ValidateIBANOptions Interface ### Description Defines the configuration options available when performing IBAN validation. ### Properties - **allowQRIBAN** (boolean) - Optional - If set to true, allows QR-IBANs to be considered valid during the validation process. ### Usage Example ```typescript const options: ValidateIBANOptions = { allowQRIBAN: true }; ``` ``` -------------------------------- ### Validate QR-IBAN format with isQRIBAN Source: https://github.com/simplify/ibantools/blob/master/docs/functions/isQRIBAN.html Checks if an IBAN string is a valid QR-IBAN. The function returns true if the input matches the QR-IBAN structure and false otherwise. ```typescript import { isQRIBAN } from 'ibantools'; // Returns true isQRIBAN("CH4431999123000889012"); // Returns false isQRIBAN("NL92ABNA0517164300"); ``` -------------------------------- ### ComposeIBANParams Interface Source: https://github.com/simplify/ibantools/blob/master/docs/interfaces/ComposeIBANParams.html Defines the parameters required for composing an IBAN. Both BBAN and country code are optional. ```APIDOC ## Interface: ComposeIBANParams ### Description Interface for ComposeIBAN parameters. ### Properties #### `Optional` bban - **Type**: string - **Description**: The Basic Bank Account Number (BBAN). #### `Optional` countryCode - **Type**: string - **Description**: The two-letter ISO country code. ### Request Example ```json { "bban": "123456789012345678", "countryCode": "DE" } ``` ### Response Example (Note: This interface defines request parameters, not direct responses. A successful composition would return the generated IBAN string.) ```json { "iban": "DE89370400440532013000" } ``` ``` -------------------------------- ### Format IBAN to Electronic Format Source: https://github.com/simplify/ibantools/blob/master/docs/functions/electronicFormatIBAN.html This function takes an IBAN string and removes all spaces to return the electronic format. It is useful for normalizing input before processing or storage. ```typescript import { electronicFormatIBAN } from 'ibantools'; // returns "NL91ABNA0417164300" const formatted = electronicFormatIBAN("NL91 ABNA 0417 1643 00"); ``` -------------------------------- ### Extract IBAN details using extractIBAN Source: https://github.com/simplify/ibantools/blob/master/docs/functions/extractIBAN.html This snippet demonstrates how to use the extractIBAN function to parse a formatted IBAN string. It accepts a string input and returns an object containing parsed components and validation status. ```typescript import { extractIBAN } from "ibantools"; const result = extractIBAN("NL91 ABNA 0417 1643 00"); console.log(result); // Returns: {iban: "NL91ABNA0417164300", bban: "ABNA0417164300", countryCode: "NL", valid: true, accountNumber: '0417164300', bankIdentifier: 'ABNA'} ``` -------------------------------- ### Define ComposeIBANParams Interface Source: https://github.com/simplify/ibantools/blob/master/docs/interfaces/ComposeIBANParams.html This interface outlines the structure for parameters used when composing an IBAN. It includes optional properties for the BBAN and the country code. ```typescript interface ComposeIBANParams { bban?: string; countryCode?: string; } ``` -------------------------------- ### Validate BIC Functionality - IBANTools Source: https://github.com/simplify/ibantools/blob/master/docs/functions/validateBIC.html This snippet demonstrates how to use the validateBIC function from the IBANTools library. It takes an optional BIC string as input and returns an array of ValidateBICResult objects, indicating the validity and any error codes associated with the BIC. ```typescript import * as ibantools from "../src/ibantools"; // Example usage: const bicValidationResult = ibantools.validateBIC("NEDSZAJJXXX"); console.log(bicValidationResult); ``` -------------------------------- ### Extract BIC Information using IBANTools Source: https://github.com/simplify/ibantools/blob/master/docs/functions/extractBIC.html This function parses a provided BIC string and returns an object containing the bank code, country code, location code, branch code, and validation status. It requires a valid BIC string as input. ```typescript import { ibantools } from "ibantools"; const result = ibantools.extractBIC("ABNANL2A"); console.log(result); // Output: {bankCode: "ABNA", countryCode: "NL", locationCode: "2A", branchCode: null, testBIC: false, valid: true} ``` -------------------------------- ### ExtractIBANResult Interface Source: https://github.com/simplify/ibantools/blob/master/docs/interfaces/ExtractIBANResult.html Defines the structure for the result of an IBAN extraction operation. It includes optional fields for account number, bank identifier, BBAN, branch identifier, and country code, along with the mandatory IBAN and a boolean indicating validity. ```APIDOC ## Interface ExtractIBANResult ### Description Interface for ExtractIBAN result. ### Fields #### `Optional` accountNumber (string) - Description: The account number extracted from the IBAN. - Defined in: ibantools.ts:271 #### `Optional` bankIdentifier (string) - Description: The bank identifier extracted from the IBAN. - Defined in: ibantools.ts:273 #### `Optional` bban (string) - Description: The Basic Bank Account Number (BBAN). - Defined in: ibantools.ts:269 #### `Optional` branchIdentifier (string) - Description: The branch identifier extracted from the IBAN. - Defined in: ibantools.ts:272 #### `Optional` countryCode (string) - Description: The two-letter country code of the IBAN. - Defined in: ibantools.ts:270 #### iban (string) - Description: The International Bank Account Number. - Required: Yes - Defined in: ibantools.ts:268 #### valid (boolean) - Description: Indicates whether the extracted IBAN is valid. - Required: Yes - Defined in: ibantools.ts:274 ### Example Request Body (Conceptual) ```json { "accountNumber": "1234567890", "bankIdentifier": "XYZBANK", "bban": "1234567890", "branchIdentifier": "001", "countryCode": "GB", "iban": "GB29NWBK60161331028605", "valid": true } ``` ### Example Success Response (Conceptual) ```json { "accountNumber": "1234567890", "bankIdentifier": "XYZBANK", "bban": "1234567890", "branchIdentifier": "001", "countryCode": "GB", "iban": "GB29NWBK60161331028605", "valid": true } ``` ``` -------------------------------- ### Interface: CountryMap Source: https://github.com/simplify/ibantools/blob/master/docs/interfaces/CountryMap.html The CountryMap interface serves as an indexable map where keys are country codes (string) and values are CountrySpec objects. ```APIDOC ## Interface: CountryMap ### Description Represents a collection of country-specific IBAN validation and formatting specifications. It is an indexable object where the key is the ISO country code. ### Definition ```typescript interface CountryMap { [code: string]: CountrySpec; } ``` ### Indexable - **code** (string) - The ISO country code (e.g., 'DE', 'GB', 'FR'). - **value** (CountrySpec) - The specification object containing validation rules for that country. ### Implementation Details - **Defined in**: ibantools.ts:587 - **Library**: IBANTools ``` -------------------------------- ### electronicFormatIBAN Source: https://github.com/simplify/ibantools/blob/master/docs/functions/electronicFormatIBAN.html Converts an IBAN string into its electronic format by removing all spaces. This function does not perform validation and returns null if the input is not a string. ```APIDOC ## electronicFormatIBAN ### Description Converts an IBAN string into its electronic format (no spaces). This function does not perform validation. If a non-string value is provided, it returns null. ### Method Function Call ### Endpoint electronicFormatIBAN(iban?: string) ### Parameters #### Path Parameters - **iban** (string) - Optional - The IBAN string to format. ### Request Example ```javascript ibantools.electronicFormatIBAN("NL91 ABNA 0417 1643 00"); ``` ### Response #### Success Response (200) - **result** (string | null) - The formatted IBAN string without spaces, or null if input was invalid. #### Response Example ```json "NL91ABNA0417164300" ``` ``` -------------------------------- ### Extract IBAN Components Source: https://context7.com/simplify/ibantools/llms.txt Parses an IBAN string into its constituent parts such as country code, bank identifier, and account number. It automatically normalizes input by removing spaces or dashes. ```javascript const ibantools = require('ibantools'); const result = ibantools.extractIBAN("NL91 ABNA 0417 1643 00"); console.log(result); ``` -------------------------------- ### IBAN Validation API Source: https://context7.com/simplify/ibantools/llms.txt Methods for validating IBAN and BIC formats and checksums. ```APIDOC ## GET /validate/iban ### Description Validates an IBAN string for correct format and checksum. ### Method GET ### Endpoint /validate/iban ### Parameters #### Query Parameters - **iban** (string) - Required - The IBAN string to validate. ### Response #### Success Response (200) - **valid** (boolean) - Indicates if the IBAN is valid. - **error** (string) - Optional error message if invalid. ### Response Example { "valid": true } ``` -------------------------------- ### Check for QR-IBAN Format Source: https://context7.com/simplify/ibantools/llms.txt Verifies if an IBAN is a valid QR-IBAN, specifically used for Swiss QR-bills. This function checks for Swiss/Liechtenstein country codes and specific bank code ranges. ```javascript const ibantools = require('ibantools'); console.log(ibantools.isQRIBAN("CH4431999123000889012")); console.log(ibantools.isQRIBAN("CH9300762011623852957")); console.log(ibantools.isQRIBAN("NL91ABNA0417164300")); ``` -------------------------------- ### isQRIBAN Function Source: https://github.com/simplify/ibantools/blob/master/docs/functions/isQRIBAN.html Checks if a given IBAN is a QR-IBAN. This function takes an IBAN string as input and returns a boolean indicating whether it is a valid QR-IBAN. ```APIDOC ## isQRIBAN Function ### Description Checks if the provided IBAN string is a QR-IBAN. ### Method N/A (This is a library function, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript ibantools.isQRIBAN("CH4431999123000889012"); // returns true ibantools.isQRIBAN("NL92ABNA0517164300"); // returns false ``` ### Response #### Success Response (boolean) - **true**: if the IBAN is a QR-IBAN - **false**: if the IBAN is not a QR-IBAN #### Response Example ```json true ``` #### Error Response N/A ``` -------------------------------- ### Validate IBAN Format and Checksum - JavaScript Source: https://context7.com/simplify/ibantools/llms.txt Checks if a given string is a valid IBAN in electronic format. It returns true for valid IBANs and false otherwise. Optionally, it can disallow QR-IBANs. Handles null or undefined inputs by returning false. ```javascript const ibantools = require('ibantools'); // Valid IBAN validation console.log(ibantools.isValidIBAN("NL91ABNA0417164300")); // true console.log(ibantools.isValidIBAN("DE89370400440532013000")); // true // Invalid IBAN (wrong checksum) console.log(ibantools.isValidIBAN("NL92ABNA0517164300")); // false // QR-IBAN validation (Swiss/Liechtenstein) console.log(ibantools.isValidIBAN("CH4431999123000889012")); // true (QR-IBAN allowed by default) console.log(ibantools.isValidIBAN("CH4431999123000889012", { allowQRIBAN: false })); // false // Handling null/undefined console.log(ibantools.isValidIBAN(null)); // false console.log(ibantools.isValidIBAN(undefined)); // false ``` -------------------------------- ### Configure Custom BBAN Validation Source: https://context7.com/simplify/ibantools/llms.txt Allows developers to inject custom validation logic for specific country BBANs. This is useful for implementing stricter business rules beyond standard format checks. ```javascript const ibantools = require('ibantools'); const customDutchValidation = (bban) => { const allowedBanks = ["ABNA", "INGB", "RABO"]; const bankCode = bban.substring(0, 4); return allowedBanks.includes(bankCode); }; ibantools.setCountryBBANValidation("NL", customDutchValidation); console.log(ibantools.isValidIBAN("NL91ABNA0417164300")); ``` -------------------------------- ### Function: isValidIBAN Source: https://github.com/simplify/ibantools/blob/master/docs/functions/isValidIBAN.html Validates an IBAN string against standard rules, with optional configuration for specific validation requirements. ```APIDOC ## Function: isValidIBAN ### Description Validates an IBAN string to ensure it conforms to the expected format and checksum requirements. Returns a boolean indicating validity. ### Method Function Call ### Parameters #### Path Parameters - **iban** (string) - Required - The IBAN string to validate. - **validationOptions** (ValidateIBANOptions) - Optional - Configuration object for validation rules (e.g., allowQRIBAN). ### Request Example ```javascript ibantools.isValidIBAN("NL91ABNA0417164300"); ``` ### Response #### Success Response (boolean) - **result** (boolean) - Returns true if the IBAN is valid, false otherwise. #### Response Example ```json true ``` ``` -------------------------------- ### Extract BIC/SWIFT Components Source: https://context7.com/simplify/ibantools/llms.txt Parses an 8 or 11-character BIC code into its constituent parts: bank code, country code, location code, and branch code. It also detects if the code is a test BIC and validates the overall format. ```javascript const ibantools = require('ibantools'); const result1 = ibantools.extractBIC("ABNANL2A"); const result2 = ibantools.extractBIC("DEUTDEFF500"); const result3 = ibantools.extractBIC("ABNANL20"); const result4 = ibantools.extractBIC("INVALID"); const result5 = ibantools.extractBIC("abnanl2a"); ``` -------------------------------- ### Validate BBAN using IBANTools Source: https://github.com/simplify/ibantools/blob/master/docs/functions/isValidBBAN.html This function validates a Basic Bank Account Number (BBAN) against a given country code. It returns a boolean indicating whether the BBAN is valid. It takes an optional BBAN string and an optional country code string as parameters. ```typescript import * as ibantools from "../src/ibantools"; // returns true ibantools.isValidBBAN("ABNA0417164300", "NL"); // returns false ibantools.isValidBBAN("A7NA0517164300", "NL"); ``` -------------------------------- ### Define ValidateIBANOptions Interface (TypeScript) Source: https://github.com/simplify/ibantools/blob/master/docs/interfaces/ValidateIBANOptions.html Defines the TypeScript interface for validation options in IBANTools. It includes a boolean property to control whether QR IBANs are allowed during validation. This interface is used to structure the options passed to validation functions. ```typescript interface ValidateIBANOptions { allowQRIBAN: boolean; } ``` -------------------------------- ### BIC Validation API Source: https://github.com/simplify/ibantools/blob/master/docs/index.html Method for validating BIC/SWIFT codes. ```APIDOC ## isValidBIC ### Description Checks if the provided string is a valid BIC/SWIFT code. ### Method Function Call ### Parameters - **bic** (string) - Required - The BIC string to validate. ### Response - **boolean** - Returns true if valid, false otherwise. ``` -------------------------------- ### Validate IBAN String with IBANTools Source: https://github.com/simplify/ibantools/blob/master/docs/functions/isValidIBAN.html The `isValidIBAN` function from the IBANTools library is used to validate IBAN strings. It can optionally take validation options to customize the validation process, such as disabling QRIBAN validation. The function returns a boolean indicating whether the IBAN is valid. ```typescript import * as ibantools from "../src/ibantools"; // returns true ibantools.isValidIBAN("NL91ABNA0417164300"); // returns false ibantools.isValidIBAN("NL92ABNA0517164300"); // returns true ibantools.isValidIBAN('CH4431999123000889012'); // returns false ibantools.isValidIBAN('CH4431999123000889012', { allowQRIBAN: false }); ``` -------------------------------- ### Validate BIC/SWIFT using IBANTools Source: https://github.com/simplify/ibantools/blob/master/docs/functions/isValidBIC.html The isValidBIC function from the IBANTools library validates a given BIC (Bank Identifier Code) or SWIFT (Society for Worldwide Interbank Financial Telecommunication) code. It returns a boolean indicating whether the provided BIC is valid. It expects a string as input and has no external dependencies beyond the IBANTools library itself. ```typescript import * as ibantools from "./ibantools"; // returns true ibantools.isValidBIC("ABNANL2A"); // returns true ibantools.isValidBIC("NEDSZAJJXXX"); // returns false ibantools.isValidBIC("ABN4NL2A"); // returns false ibantools.isValidBIC("ABNA NL 2A"); ``` -------------------------------- ### Validate IBAN input using getCountrySpecifications Source: https://github.com/simplify/ibantools/blob/master/docs/functions/getCountrySpecifications.html This snippet demonstrates how to use getCountrySpecifications to update an IBAN input field's pattern attribute dynamically based on a user's country selection. It retrieves the BBAN regular expression for the selected country and applies it to the input validation pattern. ```javascript $("#countries").select(function() { let country = ibantools.getCountrySpecifications()[$(this).val()]; $("input#iban").value($(this).val()); $("input#iban").attr("pattern", $(this).val() + "[0-9]{2}" + country.bban_regexp.slice(1).replace("$","")); }); ``` -------------------------------- ### IBAN Validation API Source: https://github.com/simplify/ibantools/blob/master/docs/index.html Methods for validating IBAN strings and retrieving detailed validation error codes. ```APIDOC ## isValidIBAN ### Description Checks if the provided string is a valid IBAN. ### Method Function Call ### Parameters - **iban** (string) - Required - The IBAN string to validate. ### Response - **boolean** - Returns true if valid, false otherwise. --- ## validateIBAN ### Description Validates an IBAN and returns a detailed object containing the validity status and specific error codes. ### Method Function Call ### Parameters - **iban** (string) - Required - The IBAN string to validate. ### Response - **object** - { valid: boolean, errorCodes: array } ``` -------------------------------- ### ValidationErrorsBIC Enumeration Source: https://github.com/simplify/ibantools/blob/master/docs/enums/ValidationErrorsBIC.html Details the error codes associated with BIC validation failures in the IBANTools library. ```APIDOC ## Enumeration: ValidationErrorsBIC ### Description Defines the set of possible error codes encountered when validating a Business Identifier Code (BIC). ### Members - **NoBICProvided** (0) - Indicates that no BIC was provided for validation. - **NoBICCountry** (1) - Indicates that the country associated with the BIC could not be determined. - **WrongBICFormat** (2) - Indicates that the provided BIC does not adhere to the required format. ### Usage Example ```typescript import { ValidationErrorsBIC } from 'ibantools'; const error = ValidationErrorsBIC.WrongBICFormat; if (error === 2) { console.log('Invalid BIC format detected.'); } ``` ``` -------------------------------- ### ValidationErrorsIBAN Enumeration Source: https://github.com/simplify/ibantools/blob/master/docs/enums/ValidationErrorsIBAN.html A reference of error codes returned when an IBAN validation fails. ```APIDOC ## Enumeration: ValidationErrorsIBAN ### Description Represents the set of possible error codes encountered during the validation of an International Bank Account Number (IBAN). ### Members - **NoIBANProvided** (0) - No IBAN string was provided for validation. - **NoIBANCountry** (1) - The country code within the IBAN is missing or invalid. - **WrongBBANLength** (2) - The Basic Bank Account Number (BBAN) length is incorrect. - **WrongBBANFormat** (3) - The BBAN format does not match the expected structure. - **ChecksumNotNumber** (4) - The checksum portion of the IBAN is not a valid number. - **WrongIBANChecksum** (5) - The calculated checksum does not match the provided IBAN checksum. - **WrongAccountBankBranchChecksum** (6) - The specific bank or branch checksum is invalid. - **QRIBANNotAllowed** (7) - QR-IBAN usage is not permitted in this context. ### Usage These codes are returned by the validation logic to provide specific feedback on why an IBAN failed verification. ``` -------------------------------- ### Validate BIC/SWIFT Code Source: https://context7.com/simplify/ibantools/llms.txt Checks if a string conforms to the standard 8 or 11 character BIC/SWIFT format. Returns a boolean indicating validity. ```javascript const ibantools = require('ibantools'); console.log(ibantools.isValidBIC("ABNANL2A")); ``` -------------------------------- ### CountrySpec Interface Definition - TypeScript Source: https://github.com/simplify/ibantools/blob/master/docs/interfaces/CountrySpec.html Defines the CountrySpec interface for IBAN country specifications. It includes properties like IBANRegistry, SEPA compliance, a regular expression for the BBAN format, and the expected number of characters in the IBAN. ```typescript interface CountrySpec { [IBANRegistry](CountrySpec.html#IBANRegistry): boolean; [SEPA](CountrySpec.html#SEPA): boolean; [bban_regexp](CountrySpec.html#bban_regexp): null | string; [chars](CountrySpec.html#chars): null | number; } ``` -------------------------------- ### Define ExtractBICResult Interface (TypeScript) Source: https://github.com/simplify/ibantools/blob/master/docs/interfaces/ExtractBICResult.html This TypeScript interface defines the structure for the result of a BIC extraction operation. It includes properties for bank code, branch code, country code, location code, and validation flags. ```typescript interface ExtractBICResult { bankCode?: string; branchCode: null | string; countryCode?: string; locationCode?: string; testBIC: boolean; valid: boolean; } ``` -------------------------------- ### Function: validateBIC Source: https://github.com/simplify/ibantools/blob/master/docs/functions/validateBIC.html Validates a given Bank Identifier Code (BIC) string and returns a result object indicating validity and any associated error codes. ```APIDOC ## validateBIC ### Description Validates the provided BIC string to ensure it conforms to standard banking formats. ### Method Function Call (JavaScript/TypeScript) ### Endpoint validateBIC(bic: string) ### Parameters #### Path Parameters - **bic** (string) - Optional - The Bank Identifier Code to validate. ### Request Example ```javascript ibantools.validateBIC("NEDSZAJJXXX"); ``` ### Response #### Success Response (200) - **valid** (boolean) - Indicates if the BIC is valid. - **errorCodes** (array) - A list of error codes if validation fails. #### Response Example { "errorCodes": [], "valid": true } ``` -------------------------------- ### Define CountryMap Interface in TypeScript Source: https://github.com/simplify/ibantools/blob/master/docs/interfaces/CountryMap.html Defines the CountryMap interface, which is an indexable type where keys are country codes (strings) and values are CountrySpec objects. This interface is used to store and access country-specific IBAN formatting and validation rules. It is defined in the ibantools.ts file. ```typescript interface CountryMap { [code: string]: CountrySpec; } ``` -------------------------------- ### isValidBIC Function Source: https://github.com/simplify/ibantools/blob/master/docs/functions/isValidBIC.html Validates a given BIC (Bank Identifier Code) or SWIFT code. ```APIDOC ## POST /simplify/ibantools/isValidBIC ### Description Validates a provided BIC (Bank Identifier Code) or SWIFT code to ensure it conforms to the standard format. ### Method POST ### Endpoint /simplify/ibantools/isValidBIC ### Parameters #### Request Body - **bic** (string) - Required - The BIC/SWIFT code to validate. ### Request Example ```json { "bic": "ABNANL2A" } ``` ### Response #### Success Response (200) - **isValid** (boolean) - True if the BIC is valid, false otherwise. #### Response Example ```json { "isValid": true } ``` #### Error Response (400) - **error** (string) - Description of the error (e.g., "Invalid BIC format"). #### Error Response Example ```json { "error": "Invalid BIC format" } ``` ``` -------------------------------- ### ExtractBICResult Interface Source: https://github.com/simplify/ibantools/blob/master/docs/interfaces/ExtractBICResult.html The ExtractBICResult interface defines the schema for the object returned after processing a BIC code, containing validation flags and specific bank identifiers. ```APIDOC ## ExtractBICResult Interface ### Description The ExtractBICResult interface represents the outcome of a BIC extraction operation. It provides details about the validity of the BIC and parses its constituent parts. ### Properties - **bankCode** (string) - Optional - The bank code component of the BIC. - **branchCode** (string | null) - Required - The branch code component of the BIC, or null if not applicable. - **countryCode** (string) - Optional - The ISO country code extracted from the BIC. - **locationCode** (string) - Optional - The location code component of the BIC. - **testBIC** (boolean) - Required - Indicates if the BIC is a test BIC. - **valid** (boolean) - Required - Indicates if the extracted BIC is valid. ### Response Example { "bankCode": "ABCD", "branchCode": "123", "countryCode": "US", "locationCode": "NY", "testBIC": false, "valid": true } ``` -------------------------------- ### extractIBAN Function Source: https://github.com/simplify/ibantools/blob/master/docs/functions/extractIBAN.html This function extracts various components of an IBAN, such as the bank account number, country code, and validation status. ```APIDOC ## POST /simplify/ibantools/extractIBAN ### Description Extracts components of an IBAN including the bank account number, country code, and validation status. ### Method POST ### Endpoint /simplify/ibantools/extractIBAN ### Parameters #### Request Body - **iban** (string) - Required - The IBAN string to process. ### Request Example ```json { "iban": "NL91 ABNA 0417 1643 00" } ``` ### Response #### Success Response (200) - **iban** (string) - The full IBAN. - **bban** (string) - The Basic Bank Account Number. - **countryCode** (string) - The two-letter country code. - **valid** (boolean) - Indicates if the IBAN is valid. - **accountNumber** (string) - The account number part of the IBAN. - **bankIdentifier** (string) - The bank identifier within the IBAN. #### Response Example ```json { "iban": "NL91ABNA0417164300", "bban": "ABNA0417164300", "countryCode": "NL", "valid": true, "accountNumber": "0417164300", "bankIdentifier": "ABNA" } ``` ``` -------------------------------- ### Set Custom BBAN Validation Function Source: https://github.com/simplify/ibantools/blob/master/docs/functions/setCountryBBANValidation.html This function registers a custom validation callback for a specified country code. If a validation function already exists for the provided country, it will be replaced by the new implementation. ```typescript /** * Set custom BBAN validation function for country. * @param country - The country code string. * @param func - A function that takes a BBAN string and returns a boolean. * @returns boolean */ function setCountryBBANValidation(country: string, func: (bban: string) => boolean): boolean { // Implementation logic to store the validation function for the given country return true; } ``` -------------------------------- ### Country Specifications Data Structure Source: https://github.com/simplify/ibantools/blob/master/docs/variables/countrySpecs.html Defines the `countrySpecs` variable, which holds country-specific information for IBAN validation and processing. This is a complex data structure likely used internally by the IBANTools library. ```typescript countrySpecs: CountryMapInternal = ... ``` -------------------------------- ### BIC Validation API Source: https://context7.com/simplify/ibantools/llms.txt Methods for validating BIC (Business Identifier Code) formats. ```APIDOC ## GET /validate/bic ### Description Validates a BIC string for correct format. ### Method GET ### Endpoint /validate/bic ### Parameters #### Query Parameters - **bic** (string) - Required - The BIC string to validate. ### Response #### Success Response (200) - **valid** (boolean) - Indicates if the BIC is valid. ### Response Example { "valid": true } ``` -------------------------------- ### Define ValidateIBANResult Interface (TypeScript) Source: https://github.com/simplify/ibantools/blob/master/docs/interfaces/ValidateIBANResult.html Defines the structure for the result of an IBAN validation, including error codes and a validity flag. This interface is used within the ibantools.ts file. ```typescript interface ValidateIBANResult { errorCodes: ValidationErrorsIBAN[]; valid: boolean; } ``` -------------------------------- ### Define ExtractIBANResult Interface in TypeScript Source: https://github.com/simplify/ibantools/blob/master/docs/interfaces/ExtractIBANResult.html This interface defines the schema for the result object returned after processing an IBAN. It includes mandatory fields for the full IBAN string and validation status, along with optional fields for specific parsed components. ```typescript interface ExtractIBANResult { accountNumber?: string; bankIdentifier?: string; bban?: string; branchIdentifier?: string; countryCode?: string; iban: string; valid: boolean; } ``` -------------------------------- ### Validate BIC with Detailed Errors Source: https://context7.com/simplify/ibantools/llms.txt Performs BIC validation and returns an object containing a validity flag and an array of error codes for debugging specific failures. ```javascript const ibantools = require('ibantools'); const result = ibantools.validateBIC("NEDSZAJJXXX"); console.log(result); ``` -------------------------------- ### Validate IBAN with Error Codes - JavaScript Source: https://context7.com/simplify/ibantools/llms.txt Validates an IBAN and provides detailed error information. It returns an object containing a 'valid' boolean and an 'errorCodes' array detailing specific validation failures. This function is useful for understanding the exact reason an IBAN is invalid. It also exposes an enum for error codes. ```javascript const ibantools = require('ibantools'); // Valid IBAN const result1 = ibantools.validateIBAN("NL91ABNA0417164300"); console.log(result1); // { valid: true, errorCodes: [] } // Invalid checksum const result2 = ibantools.validateIBAN("NL91ABNA0517164300"); console.log(result2); // { valid: false, errorCodes: [5] } // 5 = WrongIBANChecksum // No IBAN provided const result3 = ibantools.validateIBAN(""); console.log(result3); // { valid: false, errorCodes: [0] } // 0 = NoIBANProvided // Unknown country const result4 = ibantools.validateIBAN("XX91ABNA0417164300"); console.log(result4); // { valid: false, errorCodes: [1] } // 1 = NoIBANCountry // QR-IBAN not allowed const result5 = ibantools.validateIBAN("CH4431999123000889012", { allowQRIBAN: false }); console.log(result5); // { valid: false, errorCodes: [7] } // 7 = QRIBANNotAllowed // Error codes enum console.log(ibantools.ValidationErrorsIBAN); // { NoIBANProvided: 0, NoIBANCountry: 1, WrongBBANLength: 2, WrongBBANFormat: 3, // ChecksumNotNumber: 4, WrongIBANChecksum: 5, WrongAccountBankBranchChecksum: 6, QRIBANNotAllowed: 7 } ``` -------------------------------- ### Convert IBAN to Electronic Format Source: https://context7.com/simplify/ibantools/llms.txt Normalizes an IBAN string by removing all non-alphanumeric characters and converting it to uppercase. This function does not perform validation. ```javascript const ibantools = require('ibantools'); console.log(ibantools.electronicFormatIBAN("NL91-ABNA-0417-1643-00")); ``` -------------------------------- ### Validate SEPA Country Membership Source: https://context7.com/simplify/ibantools/llms.txt Determines if a given ISO country code belongs to the Single Euro Payments Area (SEPA) zone. Returns a boolean value indicating membership status. ```javascript const ibantools = require('ibantools'); console.log(ibantools.isSEPACountry("NL")); console.log(ibantools.isSEPACountry("PK")); console.log(ibantools.isSEPACountry("XX")); ``` -------------------------------- ### Validate SEPA Country Code with isSEPACountry Source: https://github.com/simplify/ibantools/blob/master/docs/functions/isSEPACountry.html The isSEPACountry function validates if a given country code belongs to a SEPA (Single Euro Payments Area) country. It takes a string country code as input and returns a boolean indicating validity. This function is useful for financial applications requiring SEPA compliance. ```typescript import * as IBANTools from "../src/ibantools"; // Example usage: console.log(IBANTools.isSEPACountry("NL")); // returns true console.log(IBANTools.isSEPACountry("PK")); // returns false ```