UNPKG

test-nino

Version:

The fastest NINO (UK National Insurance number) generator and validator. Generates and validates UK NI numbers to NIM39110 specifications on Gov.uk.

42 lines (37 loc) 1.17 kB
/** * Generates a random, valid UK National Insurance number * https://www.gov.uk/hmrc-internal-manuals/national-insurance-manual/nim39110 * @returns string */ declare const random: () => string; /** * Returns a generator instance to allow you to call `next()` * to go through all valid ni numbers in sequence, starting at * AA000000A up to ZY999999D * @returns Generator<string> */ declare const incremental: () => Generator<string>; /** * Normalises NINOs which have formatting in them * e.g. `AA 00 00 00 A` will be returned as `AA000000A` * @param nino * @returns string */ declare const normalise: (nino: string) => string; interface ValidateResult { rules?: { type?: boolean; length?: boolean; prefix?: boolean; number?: boolean; suffix?: boolean; }; outcome: boolean; } /** * Validates UK National Insurance numbers in accordance with https://www.gov.uk/hmrc-internal-manuals/national-insurance-manual/nim39110 * @param nino * @returns ValidateResult */ declare const validate: (nino: string) => ValidateResult; export { type ValidateResult, incremental, normalise, random, validate };