idnumbers
    Preparing search index...

    Interface ValidationResult<I>

    Validation result interface.

    I is the country's parse result type. validateNationalId() infers it from the country code (#123); it is ParsedInfo when the code is not known at compile time.

    interface ValidationResult<I extends object = ParsedInfo> {
        countryCode: string;
        errorMessage?: string;
        extractedInfo?: I | null;
        idNumber: string;
        isValid: boolean;
        reason?: ValidationFailureReason;
    }

    Type Parameters

    Index
    countryCode: string
    errorMessage?: string
    extractedInfo?: I | null

    What the country's parser extracted from a valid ID. null when the ID is invalid or the country has no parser; absent when the country is unsupported.

    idNumber: string
    isValid: boolean

    Machine-readable cause of the failure. Present only when isValid is false. Best-effort and non-exhaustive: derivation may fall back to a generic code rather than risk a wrong specific one, and future releases may add new values.