UNPKG

ngx-control-operators

Version:

RxJS operators for Angular reactive form controls

27 lines (26 loc) 1.19 kB
import { AbstractControl, ValidatorFn } from "@angular/forms"; import { MonoTypeOperatorFunction } from "rxjs"; /** * Applies validators to a control for each truthy emission, removes them otherwise. * * This operator works by reference. When targeting the same control in different pipes * with identical validators, if one pipe is true and the other is false, then the * operator functions will race, leading to unexpected behavior. * * This is mitigated by wrapping your validators in a {@link Validators.compose}, * with a drawback: {@link AbstractControl.hasValidator} won't work as expected. * * @param control - target to apply validators * @param validators - the validator functions to apply/remove * @returns operator function */ export declare function enforce<T>(control: AbstractControl, validators: ValidatorFn[]): MonoTypeOperatorFunction<T>; /** * Applies validators to a control for each truthy emission, removes them otherwise. * * @see {@link enforce} * @param control - target to apply validators * @param validators - the validator functions to apply/remove * @returns operator function */ export declare const applyValidators: typeof enforce;