committed by
Victor Berchet
parent
d6a58f9f70
commit
551fe50ebd
@@ -8,7 +8,7 @@
|
||||
|
||||
import {Component, Directive, EventEmitter, Input, Output, Type, forwardRef} from '@angular/core';
|
||||
import {ComponentFixture, TestBed, fakeAsync, tick} from '@angular/core/testing';
|
||||
import {AbstractControl, ControlValueAccessor, FormArray, FormControl, FormGroup, FormGroupDirective, FormsModule, NG_ASYNC_VALIDATORS, NG_VALIDATORS, NG_VALUE_ACCESSOR, NgControl, ReactiveFormsModule, Validator, Validators} from '@angular/forms';
|
||||
import {AbstractControl, AsyncValidator, ControlValueAccessor, FormArray, FormControl, FormGroup, FormGroupDirective, FormsModule, NG_ASYNC_VALIDATORS, NG_VALIDATORS, NG_VALUE_ACCESSOR, NgControl, ReactiveFormsModule, Validators} from '@angular/forms';
|
||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {dispatchEvent} from '@angular/platform-browser/testing/browser_util';
|
||||
@@ -1951,7 +1951,7 @@ class LoginIsEmptyValidator {
|
||||
multi: true
|
||||
}]
|
||||
})
|
||||
class UniqLoginValidator implements Validator {
|
||||
class UniqLoginValidator implements AsyncValidator {
|
||||
@Input('uniq-login-validator') expected: any;
|
||||
|
||||
validate(c: AbstractControl) { return uniqLoginAsyncValidator(this.expected)(c); }
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import {Component, Directive, Input, Type, forwardRef} from '@angular/core';
|
||||
import {ComponentFixture, TestBed, async, fakeAsync, tick} from '@angular/core/testing';
|
||||
import {AbstractControl, ControlValueAccessor, FormsModule, NG_ASYNC_VALIDATORS, NG_VALUE_ACCESSOR, NgForm, Validator} from '@angular/forms';
|
||||
import {AbstractControl, AsyncValidator, ControlValueAccessor, FormsModule, NG_ASYNC_VALIDATORS, NG_VALUE_ACCESSOR, NgForm} from '@angular/forms';
|
||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {dispatchEvent} from '@angular/platform-browser/testing/browser_util';
|
||||
@@ -1493,7 +1493,7 @@ class NgModelEmailValidator {
|
||||
{provide: NG_ASYNC_VALIDATORS, useExisting: forwardRef(() => NgAsyncValidator), multi: true}
|
||||
]
|
||||
})
|
||||
class NgAsyncValidator implements Validator {
|
||||
class NgAsyncValidator implements AsyncValidator {
|
||||
validate(c: AbstractControl) { return Promise.resolve(null); }
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import {AbstractControl, FormArray, FormControl, FormGroup, Validators} from '@a
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
|
||||
import {normalizeAsyncValidator} from '../src/directives/normalize_validator';
|
||||
import {AsyncValidator} from '../src/directives/validators';
|
||||
import {EventEmitter} from '../src/facade/async';
|
||||
|
||||
export function main() {
|
||||
@@ -23,10 +24,11 @@ export function main() {
|
||||
};
|
||||
}
|
||||
|
||||
class AsyncValidatorDirective {
|
||||
class AsyncValidatorDirective implements AsyncValidator {
|
||||
constructor(private expected: string, private error: any) {}
|
||||
|
||||
validate(c: any): {[key: string]: any;} {
|
||||
validate(c: any): Observable < { [key: string]: any; }
|
||||
> {
|
||||
return Observable.create((obs: any) => {
|
||||
const error = this.expected !== c.value ? this.error : null;
|
||||
obs.next(error);
|
||||
|
||||
Reference in New Issue
Block a user