Skip to content

isValidX12Date

  • Container free time, demurrage, billing deadlines, bill of lading dates and EDI timestamps.
isValidX12Date(value: string, format: X12DateFormat): boolean

Return true when value is an X12 Date Time Period value (data element 1251) that states a real calendar date in a date format qualifier (data element 1250).

  • CodeMaskThe dictionary’s definition
    D8CCYYMMDD“Date Expressed in Format CCYYMMDD”
    DBMMDDCCYY“Date Expressed in Format MMDDCCYY”
  • True exactly when parseX12Date returns a date for the same arguments: the validator calls the parser, so the two cannot disagree.

  • A value is valid only against its code: "06152024" is a DB value and not a D8 one.

  • Checks the calendar as well as the shape: 31 June and 29 February 2023 are false.

  • False for any other code, a code of another kind included; check a code alone with isValidX12DateTimePeriodFormat. False for a non-string argument.

ParameterTypeDescription
valuestringThe data element 1251 value (e.g. “20240615”)
formatX12DateFormatX12 data element 1250 format qualifier

boolean indicating validity

import { isValidX12Date } from "@northguild/gmt/intermodal/validate";
isValidX12Date("20240615", "D8") // true
output 

intermodal/validate/isValidX12Date.ts