# fhirDate

Industry: Core

```ts
const fhirDate: RegExp = /^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?$/;
```

RegExp matching a FHIR R4 `date`: the `regex` of the `date` StructureDefinition (https://hl7.org/fhir/R4/date.profile.json), verbatim and anchored.

## Examples

```ts
import { fhirDate } from "@northguild/gmt";
```

```ts
fhirDate.test("2024-06-15") // true
fhirDate.test("2024") // true (year precision)
fhirDate.test("2024-06-15T10:30:00Z") // false (a date carries no time)
fhirDate.test("0000-01-01") // false (year 0000 is not in the pattern)
fhirDate.test("2023-02-29") // true (shape only; the day does not exist)
```

## Source

[regex/fhir.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/regex/fhir.ts)
