# isValidDateRange

Industry: Core

## Signature

```ts
isValidDateRange(props: IsValidDateRangeProps): boolean
```

Return whether `value1` is before `value2`.

- Validates both dates with `isValidDate`, so an annotation of any kind on either endpoint (`[foo=bar]`, `[u-ca=iso8601]`, a time zone) returns `false`.
- Rejects leap seconds in either date.

## Options

**props**

The two values to compare and how equal values are treated

<a id="isvaliddaterangeprops"></a>

The argument object of `isValidDateRange`.

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

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `value1` | `string` | Required | The start of the range, an ISO PlainDate string. |
| `value2` | `string` | Required | The end of the range, an ISO PlainDate string. |
| `options?` | `object` | None. Equal values are not a valid range. | The settings for the comparison. It must be an object or omitted; any other value, `null` included, returns `false`. |
| `options.allowEqual?` | `boolean` | `false` | Whether `value1` equal to `value2` is a valid range. `false` requires `value1` to be before `value2`. |

## Returns

boolean indicating whether the date range is valid

## Examples

```ts
import { isValidDateRange } from "@northguild/gmt/plain/validate";

isValidDateRange({ value1: "2024-02-28", value2: "2024-02-29" }) // true
```

## Source

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