import { type CardBrand, type CardValidator } from './utils'; export type UseCardNumberValidationProps = { /** Allowed brands array, if undefined all brands allowed. This is used for validation only and will not filter the validators. */ allowedBrands?: Brand[]; /** Default card number input state */ defaultCardNumberInputValue?: string; /** Filtered brands array, if undefined no brands will be filtered. Only these brands will be checked for, the rest will be filtered out. */ filteredForBrands?: Brand[]; /** Remove all digits passed the matching card validator's max length */ trimToMaxLength?: boolean; /** Custom validators if our validators don't fit your use cases */ validators?: Record>; }; /** * @docs {@link https://design.visa.com/developing/react/hooks/usecardnumbervalidation/?code_library=react | See Docs} * @description This hook is used to to validate card numbers. This hook uses BIN regex's, length, Luhn checksum algorithm (modulo 10 check), and brands to check card number validity. This hook is designed to be flexible and allow for custom validators. * @devNote This hook's validation is not comprehensive and is subject to change. VPDS does not maintain acceptance marks for all brands for legal reasons. This hook is designed to let you bring your own validators, if custom validators are required for your use case. * @related input, select */ export declare const useCardNumberValidation: { (useCardNumberValidationOptions?: UseCardNumberValidationProps): { /** BIN is valid */ binValid: boolean; /** Brand if BIN is valid, undefined if BIN is not valid */ brand: Brand | undefined; /** The brand input is included in allowedBrands */ brandValid: boolean; /** Raw input value state sent from onCardNumberChange */ cardNumberInputValue: string; /** Card validator from BIN if BIN is matched, undefined if BIN not recognized */ cardNumberValidator: CardValidator | undefined; /** cardNumberInputValue with non digit values filtered out, and/or max characters removed */ cleanCardNumber: string; /** cleanCardNumber with the proper spacing */ formattedCardNumber: string; /** Valid last digit based off mod 10 check */ lastDigitValid: boolean; /** The card number length is valid, validated with cleanCardNumber */ lengthValid: boolean; /** Setter for cardNumberInputValue state */ onCardNumberChange: (cardNumberInputValue: string) => void; /** The card number is fully valid based on BIN regex's, allowed brands, length, and modulo 10 check */ valid: boolean; }; displayName: string; }; export default useCardNumberValidation; export * from './utils';