UNPKG

@porscheinformatik/clr-addons

Version:
33 lines (32 loc) 1.72 kB
import { AbstractControl, ValidationErrors, Validator } from '@angular/forms'; import { NullableDaterange } from '../interfaces/daterange.interface'; import { DaterangeService } from '../providers/daterange.service'; import * as i0 from "@angular/core"; /** * Validator for daterangepicker to validate that 'to' date is not after 'max' value. * Otherwise will throw corresponding `max` validation error. * * Validator is applied to the ClrDaterangepickerDirective with `max` attribute. * Or when set manually with `clrDaterangeMax` attribute. * * Validator is active by default when applied. It can be disabled with: `[clrDaterangeMax]="false"` */ export declare class ClrDaterangeMaxValidator implements Validator { private readonly daterangeService; /** Validation error name. */ static readonly validationErrorName = "max"; private _active; constructor(daterangeService: DaterangeService); /** * Disable validator by setting value to `false`. */ set active(active: boolean | string | undefined | null); /** * Validator method. Method that performs synchronous validation against the provided control. * @param control - The control to validate against. * @returns A map of validation errors if validation fails, otherwise null. */ validate(control: AbstractControl<NullableDaterange, any>): ValidationErrors | null; static ɵfac: i0.ɵɵFactoryDeclaration<ClrDaterangeMaxValidator, [{ optional: true; }]>; static ɵdir: i0.ɵɵDirectiveDeclaration<ClrDaterangeMaxValidator, "[clrDaterangepicker][max], [clrDaterangeMax]", never, { "active": { "alias": "clrDaterangeMax"; "required": false; }; }, {}, never, never, false, never>; }