isValidEpcisEvent
Signature
Section titled “Signature”isValidEpcisEvent(event: unknown): booleanValidate whether a value carries the two required time fields of a GS1 EPCIS 2.0 event, each in the grammar GS1 publishes for it.
- EPCIS (ISO/IEC 19987) is GS1’s event standard for supply-chain visibility. True exactly when
isValidEpcisEventTimeis true ofeventTimeandisValidEpcisTimeZoneOffsetis true ofeventTimeZoneOffset: this validator calls the two, and no check needs both fields at once.parseEpcisEventreturns a result for exactly the same values. eventTimemust matchepcisEventTime(theDateTimeStamppattern of the EPCIS XSD, the XML binding; the JSON schema says onlyformat: date-time) and name a real instant:YYYY-MM-DDTHH:MM:SS, an optional fraction of up to nine digits, thenZor a±HH:MMoffset. A day the month does not have (2024-02-30) is false, although the pattern matches it.eventTimeZoneOffsetmust matchepcisTimeZoneOffset(the pattern the EPCIS JSON schema gives; the XSD types the field as a barexsd:string):±HH:MMfrom-14:00to+14:00, the rule of EPCIS Standard Release 2.0 §7.4.1 (https://ref.gs1.org/standards/epcis/). A missing offset,Z,+0200and+02are false.- The two fields are independent: an
eventTimewritten with one offset and aneventTimeZoneOffsetthat is another is valid. EPCIS 2.0 §7.4.1.1 (non-normative): “there is no requirement that the time zone specifier in the XML representation of eventTime be the local time zone offset where the event was captured”. - GMT rule: a fraction longer than nine digits is false. The XSD allows any length; an instant holds nanoseconds, and
parseEpcisEventdoes not drop digits. - Only the two fields are checked.
recordTimeand every other member are ignored, so this does not validate a whole event against the EPCIS schema. - Returns false for a value that is not an object.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
event | unknown | candidate EPCIS event, or any object with eventTime and eventTimeZoneOffset |
Returns
Section titled “Returns”boolean indicating whether parseEpcisEvent reads the event, or false on invalid input
Examples
Section titled “Examples”import { isValidEpcisEvent } from "@northguild/gmt/intermodal/validate";
isValidEpcisEvent({ eventTime: "2024-06-15T14:30:00Z", eventTimeZoneOffset: "-05:00" }) // true