UNPKG

ajt-validator

Version:

Validation library for JavaScript and TypeScript

34 lines (33 loc) 1.25 kB
import { BaseValidator } from "../base"; import { ValidationResult } from "../../interfaces"; export interface BankAccountValidatorOptions { accountNumberRequired?: boolean; routingNumberRequired?: boolean; accountNameRequired?: boolean; bankNameRequired?: boolean; accountTypeRequired?: boolean; allowedAccountTypes?: string[]; minAccountNumberLength?: number; maxAccountNumberLength?: number; routingNumberPattern?: RegExp; validateRoutingChecksum?: boolean; } export interface BankAccountData { accountNumber?: string; routingNumber?: string; accountName?: string; bankName?: string; accountType?: string; } export type BankAccountValidationResult = ValidationResult<BankAccountData>; export declare class BankAccountValidator extends BaseValidator<BankAccountData> { private options; constructor(options?: BankAccountValidatorOptions); validate(bankAccount: BankAccountData): BankAccountValidationResult; /** * Validates the checksum for a US routing number using the ABA algorithm * Each digit is multiplied by a weight (3, 7, or 1) based on position * The sum of these products should be divisible by 10 */ private validateRoutingChecksum; }