@fifteen/design-system-vue
Version:
Vue 3 (Composition API + Typescript) implementation of the Fifteen Design System
35 lines (34 loc) • 1.39 kB
TypeScript
export type CreditCardBrandId = 'americanExpress' | 'dinersClub' | 'discover' | 'jcb' | 'mastercard' | 'unionpay' | 'visa';
type CreditCardBrandName = 'American Express' | 'Diners Club' | 'Discover' | 'JCB' | 'Mastercard' | 'UnionPay' | 'Visa';
type CreditCardSecurityCodeLabel = 'CVV' | 'CVC' | 'CID' | 'CVN';
type Range = [number, number];
type CreditCardPattern = number | Range;
export type CreditCardInfo = {
name: CreditCardBrandName;
type: CreditCardBrandId;
patterns: CreditCardPattern[];
lengths: number[];
code: {
size: 3 | 4;
name: CreditCardSecurityCodeLabel;
};
mask: string | string[];
};
export declare const cardTypes: CreditCardInfo[];
/**
* Checks if a card number matches with a provided pattern.
* @param cardNumber - The card number to check for a match.
* @param pattern - The pattern used for comparison.
*/
export declare function matchCardNumberByPattern(cardNumber: string, pattern: CreditCardPattern): boolean;
/**
* Returns credit card information based on a value that is usually coming from an input.
* @param value - The input value.
*/
export declare function getCardInfo(value: string): CreditCardInfo | null;
/**
* Checks if a card number is valid using the Luhn algorithm.
* @param cardNumber - The card number to check.
*/
export declare function luhnCheck(cardNumber: string): boolean;
export {};