isValidEdifactDate
Signature
Section titled “Signature”isValidEdifactDate(value: string, format: "102"): booleanReturn true when value is a UN/EDIFACT DTM value (data element 2380) that states a real calendar date in a date format code (data element 2379).
-
Format code
Section titled “Format code”Code Mask The directory’s description 102CCYYMMDD“Calendar date: C = Century ; Y = Year ; M = Month ; D = Day.” -
True exactly when
parseEdifactDatereturns a date for the same arguments: the validator calls the parser, so the two cannot disagree. -
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
isValidEdifactDtmFormat. False for a non-string argument.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | The data element 2380 value (e.g. “20240615”) |
format | "102" | The data element 2379 format code |
Returns
Section titled “Returns”boolean indicating validity
Related types
Section titled “Related types”Examples
Section titled “Examples”import { isValidEdifactDate } from "@northguild/gmt/intermodal/validate";
isValidEdifactDate("20240615", "102") // true