diff --git a/packages/forms/src/directives.ts b/packages/forms/src/directives.ts index 101a6103c9..cd7a8cb9b3 100644 --- a/packages/forms/src/directives.ts +++ b/packages/forms/src/directives.ts @@ -58,9 +58,7 @@ export const SHARED_FORM_DIRECTIVES: Type[] = [ NgControlStatus, NgControlStatusGroup, RequiredValidator, - MinValidator, MinLengthValidator, - MaxValidator, MaxLengthValidator, PatternValidator, CheckboxRequiredValidator, diff --git a/packages/forms/src/forms.ts b/packages/forms/src/forms.ts index b1f882d1d4..81caaa2dca 100644 --- a/packages/forms/src/forms.ts +++ b/packages/forms/src/forms.ts @@ -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'; diff --git a/packages/forms/test/template_integration_spec.ts b/packages/forms/test/template_integration_spec.ts index 9368dd859a..e734eabcf3 100644 --- a/packages/forms/test/template_integration_spec.ts +++ b/packages/forms/test/template_integration_spec.ts @@ -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(() => { diff --git a/tools/public_api_guard/forms/forms.d.ts b/tools/public_api_guard/forms/forms.d.ts index 398d80c064..5015340bef 100644 --- a/tools/public_api_guard/forms/forms.d.ts +++ b/tools/public_api_guard/forms/forms.d.ts @@ -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)[]>;