ValidatorOptional

maxDate

Reject a date after max.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrDatePicker } from 'ngwr/date-picker';
import { WrValidators } from 'ngwr/validators';

@Component({ imports: [WrDatePicker] })
export class MyComponent {}

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'),
]);

API

NameDescriptionTypeDefault
signatureCall it with a Date, an ISO string or epoch ms. A date-only string is local midnight.(max: Date | string | number) => ValidatorFn—
error keyOn failure: { maxDate: { max } }, the bound as you passed it. Empty value passes.{ maxDate: { max } }—

See also