isValidX12DateTime
Signature
Section titled “Signature”isValidX12DateTime(value: string, format: X12DateTimeFormat): booleanReturn true when value is an X12 Date Time Period value (data element 1251) that states a real date and time in a date-time format qualifier (data element 1250).
-
Format codes
Section titled “Format codes”Code Mask The dictionary’s definition DTCCYYMMDDHHMM“Date and Time Expressed in Format CCYYMMDDHHMM” RTSCCYYMMDDHHMMSS“Date and Time Expressed in Format CCYYMMDDHHMMSS” -
True exactly when
parseX12DateTimereturns a date-time for the same arguments: the validator calls the parser, so the two cannot disagree. -
A value is valid only against its code:
"202406151430"is aDTvalue and not anRTSone. -
Checks the calendar as well as the shape: 31 June, 29 February 2023, hour 24 and second 60 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. “202406151430”) |
format | X12DateTimeFormat | X12 data element 1250 format qualifier |
Returns
Section titled “Returns”boolean indicating validity
Related types
Section titled “Related types”Examples
Section titled “Examples”import { isValidX12DateTime } from "@northguild/gmt/intermodal/validate";
isValidX12DateTime("202406151430", "DT") // true