nationid - v2.2.1
    Preparing search index...

    Function extractDOB

    • Returns the date of birth encoded in input, or null if the spec does not encode DOB or the input fails validation.

      The returned DateOfBirth is a plain calendar date (year/month/day) — NOT a Date instance — to side-step timezone semantics. See DateOfBirth.

      Parameters

      • code: CodesSupporting<"dob">

        Document type. Must support "dob" (see supports).

      • input: string

        Raw user input; will be normalized and validated first.

      Returns DateOfBirth | null

      A DateOfBirth on success, null otherwise.

      import { extractDOB } from "nationid/extract";

      extractDOB("MX_CURP", "GOMC850315HDFRRR07");
      // { year: 1985, month: 3, day: 15 }
      extractDOB("SV_DUI", "045678903"); // null (DUI does not encode DOB)