# isValidX12DateTime

Industry: Intermodal

## Signature

```ts
isValidX12DateTime(value: string, format: X12DateTimeFormat): boolean
```

Return 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

  | Code | Mask | The dictionary's definition |
  |---|---|---|
  | `DT` | `CCYYMMDDHHMM` | "Date and Time Expressed in Format CCYYMMDDHHMM" |
  | `RTS` | `CCYYMMDDHHMMSS` | "Date and Time Expressed in Format CCYYMMDDHHMMSS" |

- True exactly when `parseX12DateTime` returns a date-time for the same arguments: the validator and the parser share one core, so the two cannot disagree.
- A value is valid only against its code: `"202406151430"` is a `DT` value and not an `RTS` one.
- 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

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `string` | The data element 1251 value (e.g. "202406151430") |
| `format` | `X12DateTimeFormat` | X12 data element 1250 format qualifier |

## Returns

boolean indicating validity

## Related types

- [`X12DateTimeFormat`](/gmt/reference/types/X12DateTimeFormat/)

## Examples

```ts
import { isValidX12DateTime } from "@northguild/gmt/intermodal/validate";

isValidX12DateTime("202406151430", "DT") // true
```

## Source

[intermodal/validate/isValidX12DateTime.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/intermodal/validate/isValidX12DateTime.ts)
