UNPKG

polish-validators

Version:

A set of validator functions that check common polish numbers.

33 lines (32 loc) 1.48 kB
/** * Validates a NIP (Polish tax identification number) string. * This function checks the format of the NIP, ensuring it has either 10 or 13 digits, * is not all zeros, and meets a specific checksum requirement. Any dashes or whitespace * are ignored. * * @param {string} nip - The NIP number as a string, which may include dashes or whitespace. * @returns {boolean} `true` if the NIP is valid; `false` otherwise. */ export declare function isNipValid(nip: string): boolean; /** * Validates a NIP (Polish tax identification number) string. * This function checks the format of the NIP, ensuring it has either 10 or 13 digits, * is not all zeros, and meets a specific checksum requirement. Any dashes or whitespace * are ignored. * * @param {string} nip - The NIP number as a string, which may include dashes or whitespace. * @returns {boolean} `true` if the NIP is invalid; `false` otherwise. */ export declare const isNipInvalid: (nip: string) => boolean; export declare const NipFormat: { readonly Format3223: "3-2-2-3"; readonly Format3322: "3-3-2-2"; }; export type NipFormat = (typeof NipFormat)[keyof typeof NipFormat]; /** * Formats a valid NIP into the specified format. * @param nip - The NIP as a string or number. * @param format - The format to use for the NIP. Defaults to `3-2-2-3`. * @returns The formatted NIP string. */ export declare function formatNip(nip: string, format?: NipFormat): string;