Validator

maxDate

Value (Date or anything new Date() parses) must be ≤ max. Empty values pass.

Live demo

Maximum is 2026-12-31 — later dates fail.

errors: null

Usage

import { FormControl } from '@angular/forms';
import { WrValidators } from 'ngwr/validators';

const end = new FormControl('', [
  WrValidators.maxDate('2026-12-31'),
]);

Why ngwr provides this

Angular's Validators.max is numeric-only. This compares dates — Date instances or anything new Date() parses — and pairs naturally with wr-date-picker.

API

NameDescriptionTypeDefault
signatureFactory — call with a Date or any value new Date(v) accepts.(max: Date | string | number) => ValidatorFn
error keyOn failure: { maxDate: { max: Date } }. Empty value passes.{ maxDate: { max } }

See also