@pix.js/validator
Version:
Validate Pix keys and QRCode
39 lines (33 loc) • 1.36 kB
TypeScript
export { getPixKeyType } from '@pix.js/core';
type ValidateOptions = {
/**
* If true, the validator will throw an error if the qrcode is invalid
* Defaults to false
*/
throwError?: boolean;
};
/**
* Validates a dynamic PIX QR code payload
* @param payload The QR code payload string to validate
* @param options Validation options
* @param options.throwError If true, throws an error when validation fails. Defaults to false
* @returns True if the payload is valid, false otherwise
* @throws {Error} If validation fails and throwError is true
*/
declare const isValidDynamicQrCode: (payload: string, options?: ValidateOptions) => boolean;
/**
* Validates a PIX key
* @param key The key to validate
* @returns True if the key is valid, false otherwise
*/
declare function isPixKey(key: string): boolean;
/**
* Validates a static PIX QR code payload
* @param payload The QR code payload string to validate
* @param options Validation options
* @param options.throwError If true, throws an error when validation fails. Defaults to false
* @returns True if the payload is valid, false otherwise
* @throws {Error} If validation fails and throwError is true
*/
declare const isValidStaticQrCode: (payload: string, options?: ValidateOptions) => boolean;
export { isPixKey, isValidDynamicQrCode, isValidStaticQrCode };