fix(forms): properly validate blank strings with minlength (#12091)

This commit is contained in:
Pawel Kozlowski
2016-10-07 00:12:09 +02:00
committed by Tobias Bosch
parent 0254ce1f6c
commit f50c1da4e2
2 changed files with 22 additions and 12 deletions

View File

@ -51,11 +51,23 @@ export function main() {
});
describe('minLength', () => {
it('should not error on an empty string',
() => { expect(Validators.minLength(2)(new FormControl(''))).toEqual(null); });
it('should error on an empty string', () => {
expect(Validators.minLength(2)(new FormControl(''))).toEqual({
'minlength': {'requiredLength': 2, 'actualLength': 0}
});
});
it('should not error on null',
() => { expect(Validators.minLength(2)(new FormControl(null))).toEqual(null); });
it('should error on null', () => {
expect(Validators.minLength(2)(new FormControl(null))).toEqual({
'minlength': {'requiredLength': 2, 'actualLength': 0}
});
});
it('should error on undefined', () => {
expect(Validators.minLength(2)(new FormControl(null))).toEqual({
'minlength': {'requiredLength': 2, 'actualLength': 0}
});
});
it('should not error on valid strings',
() => { expect(Validators.minLength(2)(new FormControl('aa'))).toEqual(null); });