feat(forms/validators): pattern validator
Adding static pattern validation method to Validators Adding a directive for the pattern validator Applying clang-format rules to modified files Updating public api spec for new pattern validator Adding pattern validator to public api guard tool For #5411 Closes #5561
This commit is contained in:
@@ -66,12 +66,28 @@ export function main() {
|
||||
it("should not error on valid strings",
|
||||
() => { expect(Validators.maxLength(2)(new Control("aa"))).toEqual(null); });
|
||||
|
||||
it("should error on short strings", () => {
|
||||
it("should error on long strings", () => {
|
||||
expect(Validators.maxLength(2)(new Control("aaa")))
|
||||
.toEqual({"maxlength": {"requiredLength": 2, "actualLength": 3}});
|
||||
});
|
||||
});
|
||||
|
||||
describe("pattern", () => {
|
||||
it("should not error on an empty string",
|
||||
() => { expect(Validators.pattern("[a-zA-Z ]*")(new Control(""))).toEqual(null); });
|
||||
|
||||
it("should not error on null",
|
||||
() => { expect(Validators.pattern("[a-zA-Z ]*")(new Control(null))).toEqual(null); });
|
||||
|
||||
it("should not error on valid strings",
|
||||
() => { expect(Validators.pattern("[a-zA-Z ]*")(new Control("aaAA"))).toEqual(null); });
|
||||
|
||||
it("should error on failure to match string", () => {
|
||||
expect(Validators.pattern("[a-zA-Z ]*")(new Control("aaa0")))
|
||||
.toEqual({"pattern": {"requiredPattern": "^[a-zA-Z ]*$", "actualValue": "aaa0"}});
|
||||
});
|
||||
});
|
||||
|
||||
describe("compose", () => {
|
||||
it("should return null when given null",
|
||||
() => { expect(Validators.compose(null)).toBe(null); });
|
||||
|
||||
@@ -427,6 +427,8 @@ var NG_COMMON = [
|
||||
'ObservableListDiffFactory.create():dart',
|
||||
'ObservableListDiffFactory.supports():dart',
|
||||
'ObservableListDiffFactory:dart',
|
||||
'PatternValidator',
|
||||
'PatternValidator.validate()',
|
||||
'PercentPipe',
|
||||
'PercentPipe.transform()',
|
||||
'RequiredValidator',
|
||||
@@ -452,6 +454,7 @@ var NG_COMMON = [
|
||||
'Validators#maxLength()',
|
||||
'Validators#minLength()',
|
||||
'Validators#nullValidator()',
|
||||
'Validators#pattern()',
|
||||
'Validators#required()',
|
||||
'RadioButtonState',
|
||||
'RadioButtonState.checked',
|
||||
|
||||
Reference in New Issue
Block a user