revert: fix(forms): temp roll back breaking change with min/max directives
This reverts commit 232bd9395dbae3a22467aa669126d50cbaa7ce56.
This commit is contained in:
parent
2447bd1bac
commit
6c8e7dd63e
@ -58,7 +58,9 @@ export const SHARED_FORM_DIRECTIVES: Type<any>[] = [
|
|||||||
NgControlStatus,
|
NgControlStatus,
|
||||||
NgControlStatusGroup,
|
NgControlStatusGroup,
|
||||||
RequiredValidator,
|
RequiredValidator,
|
||||||
|
MinValidator,
|
||||||
MinLengthValidator,
|
MinLengthValidator,
|
||||||
|
MaxValidator,
|
||||||
MaxLengthValidator,
|
MaxLengthValidator,
|
||||||
PatternValidator,
|
PatternValidator,
|
||||||
CheckboxRequiredValidator,
|
CheckboxRequiredValidator,
|
||||||
|
@ -38,7 +38,7 @@ export {FormArrayName} from './directives/reactive_directives/form_group_name';
|
|||||||
export {FormGroupName} from './directives/reactive_directives/form_group_name';
|
export {FormGroupName} from './directives/reactive_directives/form_group_name';
|
||||||
export {NgSelectOption, SelectControlValueAccessor} from './directives/select_control_value_accessor';
|
export {NgSelectOption, SelectControlValueAccessor} from './directives/select_control_value_accessor';
|
||||||
export {SelectMultipleControlValueAccessor} from './directives/select_multiple_control_value_accessor';
|
export {SelectMultipleControlValueAccessor} from './directives/select_multiple_control_value_accessor';
|
||||||
export {AsyncValidator, AsyncValidatorFn, CheckboxRequiredValidator, EmailValidator, MaxLengthValidator, MinLengthValidator, PatternValidator, RequiredValidator, ValidationErrors, Validator, ValidatorFn} from './directives/validators';
|
export {AsyncValidator, AsyncValidatorFn, CheckboxRequiredValidator, EmailValidator, MaxLengthValidator, MaxValidator, MinLengthValidator, MinValidator, PatternValidator, RequiredValidator, ValidationErrors, Validator, ValidatorFn} from './directives/validators';
|
||||||
export {FormBuilder} from './form_builder';
|
export {FormBuilder} from './form_builder';
|
||||||
export {AbstractControl, FormArray, FormControl, FormGroup} from './model';
|
export {AbstractControl, FormArray, FormControl, FormGroup} from './model';
|
||||||
export {NG_ASYNC_VALIDATORS, NG_VALIDATORS, Validators} from './validators';
|
export {NG_ASYNC_VALIDATORS, NG_VALIDATORS, Validators} from './validators';
|
||||||
|
@ -879,99 +879,95 @@ export function main() {
|
|||||||
|
|
||||||
describe('validation directives', () => {
|
describe('validation directives', () => {
|
||||||
|
|
||||||
// TODO(kara): activate when we start exporting max validator dir
|
it('should should validate max', fakeAsync(() => {
|
||||||
xit('should should validate max', fakeAsync(() => {
|
const fixture = initTest(NgModelMaxValidator);
|
||||||
const fixture = initTest(NgModelMaxValidator);
|
fixture.componentInstance.max = 10;
|
||||||
fixture.componentInstance.max = 10;
|
fixture.detectChanges();
|
||||||
fixture.detectChanges();
|
tick();
|
||||||
tick();
|
|
||||||
|
|
||||||
const max = fixture.debugElement.query(By.css('input'));
|
const max = fixture.debugElement.query(By.css('input'));
|
||||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||||
|
|
||||||
max.nativeElement.value = '';
|
max.nativeElement.value = '';
|
||||||
dispatchEvent(max.nativeElement, 'input');
|
dispatchEvent(max.nativeElement, 'input');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(form.valid).toEqual(true);
|
expect(form.valid).toEqual(true);
|
||||||
|
|
||||||
max.nativeElement.value = 11;
|
max.nativeElement.value = 11;
|
||||||
dispatchEvent(max.nativeElement, 'input');
|
dispatchEvent(max.nativeElement, 'input');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(form.valid).toEqual(false);
|
expect(form.valid).toEqual(false);
|
||||||
|
|
||||||
max.nativeElement.value = 9;
|
max.nativeElement.value = 9;
|
||||||
dispatchEvent(max.nativeElement, 'input');
|
dispatchEvent(max.nativeElement, 'input');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(form.valid).toEqual(true);
|
expect(form.valid).toEqual(true);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// TODO(kara): activate when we start exporting max validator dir
|
it('should validate max for strings', fakeAsync(() => {
|
||||||
xit('should validate max for strings', fakeAsync(() => {
|
const fixture = initTest(NgModelMaxValidator);
|
||||||
const fixture = initTest(NgModelMaxValidator);
|
fixture.componentInstance.max = 10;
|
||||||
fixture.componentInstance.max = 10;
|
fixture.detectChanges();
|
||||||
fixture.detectChanges();
|
tick();
|
||||||
tick();
|
|
||||||
|
|
||||||
const max = fixture.debugElement.query(By.css('input'));
|
const max = fixture.debugElement.query(By.css('input'));
|
||||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||||
|
|
||||||
max.nativeElement.value = '11';
|
max.nativeElement.value = '11';
|
||||||
dispatchEvent(max.nativeElement, 'input');
|
dispatchEvent(max.nativeElement, 'input');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(form.valid).toEqual(false);
|
expect(form.valid).toEqual(false);
|
||||||
|
|
||||||
max.nativeElement.value = '9';
|
max.nativeElement.value = '9';
|
||||||
dispatchEvent(max.nativeElement, 'input');
|
dispatchEvent(max.nativeElement, 'input');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(form.valid).toEqual(true);
|
expect(form.valid).toEqual(true);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// TODO(kara): activate when we start exporting min validator dir
|
it('should should validate min', fakeAsync(() => {
|
||||||
xit('should should validate min', fakeAsync(() => {
|
const fixture = initTest(NgModelMinValidator);
|
||||||
const fixture = initTest(NgModelMinValidator);
|
fixture.componentInstance.min = 10;
|
||||||
fixture.componentInstance.min = 10;
|
fixture.detectChanges();
|
||||||
fixture.detectChanges();
|
tick();
|
||||||
tick();
|
|
||||||
|
|
||||||
const min = fixture.debugElement.query(By.css('input'));
|
const min = fixture.debugElement.query(By.css('input'));
|
||||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||||
|
|
||||||
min.nativeElement.value = '';
|
min.nativeElement.value = '';
|
||||||
dispatchEvent(min.nativeElement, 'input');
|
dispatchEvent(min.nativeElement, 'input');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(form.valid).toEqual(true);
|
expect(form.valid).toEqual(true);
|
||||||
|
|
||||||
min.nativeElement.value = 11;
|
min.nativeElement.value = 11;
|
||||||
dispatchEvent(min.nativeElement, 'input');
|
dispatchEvent(min.nativeElement, 'input');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(form.valid).toEqual(true);
|
expect(form.valid).toEqual(true);
|
||||||
|
|
||||||
min.nativeElement.value = 9;
|
min.nativeElement.value = 9;
|
||||||
dispatchEvent(min.nativeElement, 'input');
|
dispatchEvent(min.nativeElement, 'input');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(form.valid).toEqual(false);
|
expect(form.valid).toEqual(false);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// TODO(kara): activate when we start exporting min validator dir
|
it('should should validate min for strings', fakeAsync(() => {
|
||||||
xit('should should validate min for strings', fakeAsync(() => {
|
const fixture = initTest(NgModelMinValidator);
|
||||||
const fixture = initTest(NgModelMinValidator);
|
fixture.componentInstance.min = 10;
|
||||||
fixture.componentInstance.min = 10;
|
fixture.detectChanges();
|
||||||
fixture.detectChanges();
|
tick();
|
||||||
tick();
|
|
||||||
|
|
||||||
const min = fixture.debugElement.query(By.css('input'));
|
const min = fixture.debugElement.query(By.css('input'));
|
||||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||||
|
|
||||||
min.nativeElement.value = '11';
|
min.nativeElement.value = '11';
|
||||||
dispatchEvent(min.nativeElement, 'input');
|
dispatchEvent(min.nativeElement, 'input');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(form.valid).toEqual(true);
|
expect(form.valid).toEqual(true);
|
||||||
|
|
||||||
min.nativeElement.value = '9';
|
min.nativeElement.value = '9';
|
||||||
dispatchEvent(min.nativeElement, 'input');
|
dispatchEvent(min.nativeElement, 'input');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(form.valid).toEqual(false);
|
expect(form.valid).toEqual(false);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('required validator should validate checkbox', fakeAsync(() => {
|
it('required validator should validate checkbox', fakeAsync(() => {
|
||||||
|
16
tools/public_api_guard/forms/forms.d.ts
vendored
16
tools/public_api_guard/forms/forms.d.ts
vendored
@ -352,6 +352,14 @@ export declare class MaxLengthValidator implements Validator, OnChanges {
|
|||||||
validate(c: AbstractControl): ValidationErrors | null;
|
validate(c: AbstractControl): ValidationErrors | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @experimental */
|
||||||
|
export declare class MaxValidator implements Validator, OnChanges {
|
||||||
|
max: string;
|
||||||
|
ngOnChanges(changes: SimpleChanges): void;
|
||||||
|
registerOnValidatorChange(fn: () => void): void;
|
||||||
|
validate(c: AbstractControl): ValidationErrors | null;
|
||||||
|
}
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare class MinLengthValidator implements Validator, OnChanges {
|
export declare class MinLengthValidator implements Validator, OnChanges {
|
||||||
minlength: string;
|
minlength: string;
|
||||||
@ -360,6 +368,14 @@ export declare class MinLengthValidator implements Validator, OnChanges {
|
|||||||
validate(c: AbstractControl): ValidationErrors | null;
|
validate(c: AbstractControl): ValidationErrors | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @experimental */
|
||||||
|
export declare class MinValidator implements Validator, OnChanges {
|
||||||
|
min: string;
|
||||||
|
ngOnChanges(changes: SimpleChanges): void;
|
||||||
|
registerOnValidatorChange(fn: () => void): void;
|
||||||
|
validate(c: AbstractControl): ValidationErrors | null;
|
||||||
|
}
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare const NG_ASYNC_VALIDATORS: InjectionToken<(Function | Validator)[]>;
|
export declare const NG_ASYNC_VALIDATORS: InjectionToken<(Function | Validator)[]>;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user