123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- import { InjectionToken } from '@angular/core';
- import { Observable } from 'rxjs/Observable';
- import { AsyncValidatorFn, ValidationErrors, Validator, ValidatorFn } from './directives/validators';
- import { AbstractControl } from './model';
- /**
- * Providers for validators to be used for {@link FormControl}s in a form.
- *
- * Provide this using `multi: true` to add validators.
- *
- * ### Example
- *
- * ```typescript
- * @Directive({
- * selector: '[custom-validator]',
- * providers: [{provide: NG_VALIDATORS, useExisting: CustomValidatorDirective, multi: true}]
- * })
- * class CustomValidatorDirective implements Validator {
- * validate(control: AbstractControl): ValidationErrors | null {
- * return {"custom": true};
- * }
- * }
- * ```
- *
- * @stable
- */
- export declare const NG_VALIDATORS: InjectionToken<(Function | Validator)[]>;
- /**
- * Providers for asynchronous validators to be used for {@link FormControl}s
- * in a form.
- *
- * Provide this using `multi: true` to add validators.
- *
- * See {@link NG_VALIDATORS} for more details.
- *
- * @stable
- */
- export declare const NG_ASYNC_VALIDATORS: InjectionToken<(Function | Validator)[]>;
- /**
- * Provides a set of validators used by form controls.
- *
- * A validator is a function that processes a {@link FormControl} or collection of
- * controls and returns a map of errors. A null map means that validation has passed.
- *
- * ### Example
- *
- * ```typescript
- * var loginControl = new FormControl("", Validators.required)
- * ```
- *
- * @stable
- */
- export declare class Validators {
- /**
- * Validator that requires controls to have a value greater than a number.
- *`min()` exists only as a function, not as a directive. For example,
- * `control = new FormControl('', Validators.min(3));`.
- */
- static min(min: number): ValidatorFn;
- /**
- * Validator that requires controls to have a value less than a number.
- * `max()` exists only as a function, not as a directive. For example,
- * `control = new FormControl('', Validators.max(15));`.
- */
- static max(max: number): ValidatorFn;
- /**
- * Validator that requires controls to have a non-empty value.
- */
- static required(control: AbstractControl): ValidationErrors | null;
- /**
- * Validator that requires control value to be true.
- */
- static requiredTrue(control: AbstractControl): ValidationErrors | null;
- /**
- * Validator that performs email validation.
- */
- static email(control: AbstractControl): ValidationErrors | null;
- /**
- * Validator that requires controls to have a value of a minimum length.
- */
- static minLength(minLength: number): ValidatorFn;
- /**
- * Validator that requires controls to have a value of a maximum length.
- */
- static maxLength(maxLength: number): ValidatorFn;
- /**
- * Validator that requires a control to match a regex to its value.
- */
- static pattern(pattern: string | RegExp): ValidatorFn;
- /**
- * No-op validator.
- */
- static nullValidator(c: AbstractControl): ValidationErrors | null;
- /**
- * Compose multiple validators into a single function that returns the union
- * of the individual error maps.
- */
- static compose(validators: null): null;
- static compose(validators: (ValidatorFn | null | undefined)[]): ValidatorFn | null;
- static composeAsync(validators: (AsyncValidatorFn | null)[]): AsyncValidatorFn | null;
- }
- export declare function toObservable(r: any): Observable<any>;
|