nationid - v2.2.1
    Preparing search index...

    Function validate

    • Validate input against the document type identified by code.

      Internally normalizes the input (strips separators, uppercases). Returns true only if both regex shape AND check digit pass. Never throws on malformed input — use parse() if you need the failure reason.

      Parameters

      • code: DocumentTypeCode

        Document type to validate against (e.g. "SV_DUI").

      • input: string

        Raw user input; separators and case are tolerated.

      Returns boolean

      true if input is a syntactically and check-digit valid document.

      if code is not registered.

      import { validate } from "nationid";

      validate("SV_DUI", "04567890-3"); // true
      validate("SV_NIT", "06141505851012"); // true
      validate("BR_CPF", "111.444.777-35"); // true
      validate("BR_CPF", "111.444.777-00"); // false (bad check digit)