isValidX12Date
Signature
Section titled “Signature”isValidX12Date(value: string, format: X12DateFormat): booleanReturn 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).
-
Format codes
Section titled “Format codes”Code Mask The dictionary’s definition D8CCYYMMDD“Date Expressed in Format CCYYMMDD” DBMMDDCCYY“Date Expressed in Format MMDDCCYY” -
True exactly when
parseX12Datereturns 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 aDBvalue and not aD8one. -
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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | The data element 1251 value (e.g. “20240615”) |
format | X12DateFormat | X12 data element 1250 format qualifier |
Returns
Section titled “Returns”boolean indicating validity
Related types
Section titled “Related types”Examples
Section titled “Examples”import { isValidX12Date } from "@northguild/gmt/intermodal/validate";
isValidX12Date("20240615", "D8") // true