pixkey
Version:
Identify, validate, format and normalize a Pix key type from a string
19 lines (18 loc) • 834 B
TypeScript
export declare const PIX_KEY_CPF = "cpf";
export declare const PIX_KEY_CNPJ = "cnpj";
export declare const PIX_KEY_RANDOM = "random";
export declare const PIX_KEY_EMAIL = "email";
export declare const PIX_KEY_PHONE = "phone";
export type PixKeyType = typeof PIX_KEY_CPF | typeof PIX_KEY_CNPJ | typeof PIX_KEY_RANDOM | typeof PIX_KEY_EMAIL | typeof PIX_KEY_PHONE;
/**
* Validates a given pix key and returns a list of possible key types.
*/
export declare function validate(pixKey: string): PixKeyType[];
/**
* Normalizes a pix key to a standard format depending on its type.
*/
export declare function normalize(pixKey: string, as?: PixKeyType | null): string | null;
/**
* Formats a pix key in a user-friendly way depending on its type.
*/
export declare function format(pixKey: string, as?: PixKeyType | null): string | null;