nationid - v0.6.0
    Preparing search index...

    Interface DocumentSpec

    Definition of one document type.

    Each country file under src/countries/<cc>/ exports one or more specs.

    interface DocumentSpec {
        code: DocumentTypeCode;
        confidence: Confidence;
        country: CountryCode;
        formattedRegex?: RegExp;
        hasCheckDigit: boolean;
        labelKey: string;
        mask: string;
        rawRegex: RegExp;
        scope: DocumentScope;
        format(input: string): string;
        normalize(input: string): string;
        parse(input: string): ParseResult;
        validate(input: string): boolean;
    }
    Index

    Properties

    confidence: Confidence
    country: CountryCode
    formattedRegex?: RegExp

    Optional regex matching the formatted form a user might paste.

    hasCheckDigit: boolean

    True iff the spec includes a check-digit algorithm we trust to enforce.

    labelKey: string

    i18n key path, e.g. documents.SV_DUI.label. UI consumers resolve to localized text.

    mask: string

    Mask pattern (cleave-style: 0=digit, A=uppercase letter, *=alphanumeric).

    rawRegex: RegExp

    Regex matching the normalized form (no separators, uppercase).

    Methods

    • Reverse of normalize, applies the canonical mask. Returns input unchanged if invalid.

      Parameters

      • input: string

      Returns string

    • Strip separators, uppercase, trim. Idempotent.

      Parameters

      • input: string

      Returns string

    • Returns true iff input passes regex AND (when applicable) check digit.

      Parameters

      • input: string

      Returns boolean