fix(forms): temp roll back breaking change with min/max directives
With 4.2, we introduced the min and max validator directives. This was actually a breaking change because their selectors could include custom value accessors using the min/max properties for their own purposes. For now, we are rolling back the change by removing the exports. Closes #17491.
This commit is contained in:
parent
956a7e95d7
commit
232bd9395d
|
@ -58,9 +58,7 @@ export const SHARED_FORM_DIRECTIVES: Type<any>[] = [
|
|||
NgControlStatus,
|
||||
NgControlStatusGroup,
|
||||
RequiredValidator,
|
||||
MinValidator,
|
||||
MinLengthValidator,
|
||||
MaxValidator,
|
||||
MaxLengthValidator,
|
||||
PatternValidator,
|
||||
CheckboxRequiredValidator,
|
||||
|
|
|
@ -38,7 +38,7 @@ export {FormArrayName} 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 {SelectMultipleControlValueAccessor} from './directives/select_multiple_control_value_accessor';
|
||||
export {AsyncValidator, AsyncValidatorFn, CheckboxRequiredValidator, EmailValidator, MaxLengthValidator, MaxValidator, MinLengthValidator, MinValidator, PatternValidator, RequiredValidator, ValidationErrors, Validator, ValidatorFn} from './directives/validators';
|
||||
export {AsyncValidator, AsyncValidatorFn, CheckboxRequiredValidator, EmailValidator, MaxLengthValidator, MinLengthValidator, PatternValidator, RequiredValidator, ValidationErrors, Validator, ValidatorFn} from './directives/validators';
|
||||
export {FormBuilder} from './form_builder';
|
||||
export {AbstractControl, FormArray, FormControl, FormGroup} from './model';
|
||||
export {NG_ASYNC_VALIDATORS, NG_VALIDATORS, Validators} from './validators';
|
||||
|
|
|
@ -879,95 +879,99 @@ export function main() {
|
|||
|
||||
describe('validation directives', () => {
|
||||
|
||||
it('should should validate max', fakeAsync(() => {
|
||||
const fixture = initTest(NgModelMaxValidator);
|
||||
fixture.componentInstance.max = 10;
|
||||
fixture.detectChanges();
|
||||
tick();
|
||||
// TODO(kara): activate when we start exporting max validator dir
|
||||
xit('should should validate max', fakeAsync(() => {
|
||||
const fixture = initTest(NgModelMaxValidator);
|
||||
fixture.componentInstance.max = 10;
|
||||
fixture.detectChanges();
|
||||
tick();
|
||||
|
||||
const max = fixture.debugElement.query(By.css('input'));
|
||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||
const max = fixture.debugElement.query(By.css('input'));
|
||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||
|
||||
max.nativeElement.value = '';
|
||||
dispatchEvent(max.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(true);
|
||||
max.nativeElement.value = '';
|
||||
dispatchEvent(max.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(true);
|
||||
|
||||
max.nativeElement.value = 11;
|
||||
dispatchEvent(max.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(false);
|
||||
max.nativeElement.value = 11;
|
||||
dispatchEvent(max.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(false);
|
||||
|
||||
max.nativeElement.value = 9;
|
||||
dispatchEvent(max.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(true);
|
||||
}));
|
||||
max.nativeElement.value = 9;
|
||||
dispatchEvent(max.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(true);
|
||||
}));
|
||||
|
||||
it('should validate max for strings', fakeAsync(() => {
|
||||
const fixture = initTest(NgModelMaxValidator);
|
||||
fixture.componentInstance.max = 10;
|
||||
fixture.detectChanges();
|
||||
tick();
|
||||
// TODO(kara): activate when we start exporting max validator dir
|
||||
xit('should validate max for strings', fakeAsync(() => {
|
||||
const fixture = initTest(NgModelMaxValidator);
|
||||
fixture.componentInstance.max = 10;
|
||||
fixture.detectChanges();
|
||||
tick();
|
||||
|
||||
const max = fixture.debugElement.query(By.css('input'));
|
||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||
const max = fixture.debugElement.query(By.css('input'));
|
||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||
|
||||
max.nativeElement.value = '11';
|
||||
dispatchEvent(max.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(false);
|
||||
max.nativeElement.value = '11';
|
||||
dispatchEvent(max.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(false);
|
||||
|
||||
max.nativeElement.value = '9';
|
||||
dispatchEvent(max.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(true);
|
||||
}));
|
||||
max.nativeElement.value = '9';
|
||||
dispatchEvent(max.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(true);
|
||||
}));
|
||||
|
||||
it('should should validate min', fakeAsync(() => {
|
||||
const fixture = initTest(NgModelMinValidator);
|
||||
fixture.componentInstance.min = 10;
|
||||
fixture.detectChanges();
|
||||
tick();
|
||||
// TODO(kara): activate when we start exporting min validator dir
|
||||
xit('should should validate min', fakeAsync(() => {
|
||||
const fixture = initTest(NgModelMinValidator);
|
||||
fixture.componentInstance.min = 10;
|
||||
fixture.detectChanges();
|
||||
tick();
|
||||
|
||||
const min = fixture.debugElement.query(By.css('input'));
|
||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||
const min = fixture.debugElement.query(By.css('input'));
|
||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||
|
||||
min.nativeElement.value = '';
|
||||
dispatchEvent(min.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(true);
|
||||
min.nativeElement.value = '';
|
||||
dispatchEvent(min.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(true);
|
||||
|
||||
min.nativeElement.value = 11;
|
||||
dispatchEvent(min.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(true);
|
||||
min.nativeElement.value = 11;
|
||||
dispatchEvent(min.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(true);
|
||||
|
||||
min.nativeElement.value = 9;
|
||||
dispatchEvent(min.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(false);
|
||||
}));
|
||||
min.nativeElement.value = 9;
|
||||
dispatchEvent(min.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(false);
|
||||
}));
|
||||
|
||||
it('should should validate min for strings', fakeAsync(() => {
|
||||
const fixture = initTest(NgModelMinValidator);
|
||||
fixture.componentInstance.min = 10;
|
||||
fixture.detectChanges();
|
||||
tick();
|
||||
// TODO(kara): activate when we start exporting min validator dir
|
||||
xit('should should validate min for strings', fakeAsync(() => {
|
||||
const fixture = initTest(NgModelMinValidator);
|
||||
fixture.componentInstance.min = 10;
|
||||
fixture.detectChanges();
|
||||
tick();
|
||||
|
||||
const min = fixture.debugElement.query(By.css('input'));
|
||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||
const min = fixture.debugElement.query(By.css('input'));
|
||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||
|
||||
min.nativeElement.value = '11';
|
||||
dispatchEvent(min.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(true);
|
||||
min.nativeElement.value = '11';
|
||||
dispatchEvent(min.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(true);
|
||||
|
||||
min.nativeElement.value = '9';
|
||||
dispatchEvent(min.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(false);
|
||||
}));
|
||||
min.nativeElement.value = '9';
|
||||
dispatchEvent(min.nativeElement, 'input');
|
||||
fixture.detectChanges();
|
||||
expect(form.valid).toEqual(false);
|
||||
}));
|
||||
|
||||
|
||||
it('required validator should validate checkbox', fakeAsync(() => {
|
||||
|
|
|
@ -352,14 +352,6 @@ export declare class MaxLengthValidator implements Validator, OnChanges {
|
|||
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 */
|
||||
export declare class MinLengthValidator implements Validator, OnChanges {
|
||||
minlength: string;
|
||||
|
@ -368,14 +360,6 @@ export declare class MinLengthValidator implements Validator, OnChanges {
|
|||
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 */
|
||||
export declare const NG_ASYNC_VALIDATORS: InjectionToken<(Function | Validator)[]>;
|
||||
|
||||
|
|
Loading…
Reference in New Issue