UNPKG

@ngspot/ngx-errors

Version:

<p align="center"> <img width="20%" height="20%" src="https://github.com/DmitryEfimenko/ngspot/blob/main/packages/ngx-errors/package/assets/logo.png?raw=true"> </p>

25 lines (24 loc) 1.05 kB
import { AbstractControl, ValidatorFn } from '@angular/forms'; export interface DependentValidatorOptions<T> { /** * Function that returns AbstractControl to watch * @param form - the root FormGroup of the control being validated */ watchControl: (form?: AbstractControl) => AbstractControl; /** * @param watchControlValue - the value of the control being watched * @returns ValidatorFn. Ex: Validators.required */ validator: (watchControlValue?: T) => ValidatorFn; /** * If the condition is provided, it must return true in order for the * validator to be applied. * @param watchControlValue - the value of the control being watched */ condition?: (watchControlValue?: T) => boolean; } /** * Makes it easy to trigger validation on the control, that depends on * a value of a different control */ export declare function dependentValidator<T = any>(opts: DependentValidatorOptions<T>): (formControl: AbstractControl) => import("@angular/forms").ValidationErrors | null;