Project

General

Profile

1
/**
2
 * @license
3
 * Copyright Google Inc. All Rights Reserved.
4
 *
5
 * Use of this source code is governed by an MIT-style license that can be
6
 * found in the LICENSE file at https://angular.io/license
7
 */
8
import { InjectionToken } from '@angular/core';
9
import { Observable } from 'rxjs/Observable';
10
import { AsyncValidatorFn, ValidationErrors, Validator, ValidatorFn } from './directives/validators';
11
import { AbstractControl } from './model';
12
/**
13
 * Providers for validators to be used for {@link FormControl}s in a form.
14
 *
15
 * Provide this using `multi: true` to add validators.
16
 *
17
 * @stable
18
 */
19
export declare const NG_VALIDATORS: InjectionToken<(Function | Validator)[]>;
20
/**
21
 * Providers for asynchronous validators to be used for {@link FormControl}s
22
 * in a form.
23
 *
24
 * Provide this using `multi: true` to add validators.
25
 *
26
 * See {@link NG_VALIDATORS} for more details.
27
 *
28
 * @stable
29
 */
30
export declare const NG_ASYNC_VALIDATORS: InjectionToken<(Function | Validator)[]>;
31
/**
32
 * Provides a set of validators used by form controls.
33
 *
34
 * A validator is a function that processes a {@link FormControl} or collection of
35
 * controls and returns a map of errors. A null map means that validation has passed.
36
 *
37
 * ### Example
38
 *
39
 * ```typescript
40
 * var loginControl = new FormControl("", Validators.required)
41
 * ```
42
 *
43
 * @stable
44
 */
45
export declare class Validators {
46
    /**
47
     * Validator that requires controls to have a value greater than a number.
48
     */
49
    static min(min: number): ValidatorFn;
50
    /**
51
     * Validator that requires controls to have a value less than a number.
52
     */
53
    static max(max: number): ValidatorFn;
54
    /**
55
     * Validator that requires controls to have a non-empty value.
56
     */
57
    static required(control: AbstractControl): ValidationErrors | null;
58
    /**
59
     * Validator that requires control value to be true.
60
     */
61
    static requiredTrue(control: AbstractControl): ValidationErrors | null;
62
    /**
63
     * Validator that performs email validation.
64
     */
65
    static email(control: AbstractControl): ValidationErrors | null;
66
    /**
67
     * Validator that requires controls to have a value of a minimum length.
68
     */
69
    static minLength(minLength: number): ValidatorFn;
70
    /**
71
     * Validator that requires controls to have a value of a maximum length.
72
     */
73
    static maxLength(maxLength: number): ValidatorFn;
74
    /**
75
     * Validator that requires a control to match a regex to its value.
76
     */
77
    static pattern(pattern: string | RegExp): ValidatorFn;
78
    /**
79
     * No-op validator.
80
     */
81
    static nullValidator(c: AbstractControl): ValidationErrors | null;
82
    /**
83
     * Compose multiple validators into a single function that returns the union
84
     * of the individual error maps.
85
     */
86
    static compose(validators: null): null;
87
    static compose(validators: (ValidatorFn | null | undefined)[]): ValidatorFn | null;
88
    static composeAsync(validators: (AsyncValidatorFn | null)[]): AsyncValidatorFn | null;
89
}
90
export declare function toObservable(r: any): Observable<any>;
(6-6/7)