@temboplus/frontend-core
Version:
A JavaScript/TypeScript package providing common utilities and logic shared across front-end TemboPlus projects.
81 lines (80 loc) • 3.81 kB
TypeScript
import { ISO2CountryCode } from "@models/country/country.types.js";
import { BankSwiftCode } from "./bank.types.js";
export declare const BankValidation: {
/**
* Validates a bank account number format for a specific country.
* @param accountNumber The account number string.
* @param countryCode The ISO2 country code.
* @returns True if the format is valid, false otherwise.
*/
validateAccountNumber: (accountNumber: string, countryCode: ISO2CountryCode) => boolean;
/**
* Validates a bank account number format for any supported country.
* @param accountNumber The account number string.
* @returns True if the format is valid for any supported country, false otherwise.
*/
validateAccountNumberForAnyCountry: (accountNumber: string) => boolean;
/**
* Validates a SWIFT/BIC code for a specific country.
* @param swiftCode The SWIFT code string.
* @param countryCode The ISO2 country code.
* @returns True if the format is valid, false otherwise.
*/
validateSwiftCode: (swiftCode: string, countryCode: ISO2CountryCode) => swiftCode is BankSwiftCode;
/**
* Validates a SWIFT/BIC code for any supported country.
* @param swiftCode The SWIFT code string.
* @returns True if the SWIFT code is valid for any supported country, false otherwise.
*/
validateSwiftCodeForAnyCountry: (swiftCode: string) => swiftCode is BankSwiftCode;
/**
* Validates an account name based on various criteria.
* This validation is country-agnostic as account name rules are generally similar.
*
* @param {string} accountName - The account name to validate
* @returns {boolean} True if the account name meets all validation criteria, false otherwise
*
* @example
* // Returns true
* validateAccountName("John Smith");
*
* @example
* // Returns false (too short)
* validateAccountName("Jo");
*
* @example
* // Returns false (invalid characters)
* validateAccountName("User123");
*/
validateAccountName: (accountName: string) => boolean;
/**
* Validates an account name for any supported country.
* Since account name validation is generally country-agnostic, this is an alias to validateAccountName.
* @param accountName The account name to validate.
* @returns True if the account name is valid, false otherwise.
*/
validateAccountNameForAnyCountry: (accountName: string) => boolean;
/**
* Validates all bank details (account number, SWIFT code, and account name) for a specific country.
* @param accountNumber The account number string.
* @param swiftCode The SWIFT code string.
* @param accountName The account name string.
* @param countryCode The ISO2 country code.
* @returns True if all details are valid for the specified country, false otherwise.
*/
validateAllBankDetails: (accountNumber: string, swiftCode: string, accountName: string, countryCode: ISO2CountryCode) => boolean;
/**
* Validates all bank details (account number, SWIFT code, and account name) for any supported country.
* @param accountNumber The account number string.
* @param swiftCode The SWIFT code string.
* @param accountName The account name string.
* @returns True if all details are valid for any supported country, false otherwise.
*/
validateAllBankDetailsForAnyCountry: (accountNumber: string, swiftCode: string, accountName: string) => boolean;
/**
* Determines which country a SWIFT code belongs to.
* @param swiftCode The SWIFT code string.
* @returns The ISO2 country code if found, undefined otherwise.
*/
getCountryFromSwiftCode: (swiftCode: string) => ISO2CountryCode | undefined;
};