本文整理汇总了TypeScript中angular2/common.Validators.pattern方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Validators.pattern方法的具体用法?TypeScript Validators.pattern怎么用?TypeScript Validators.pattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/common.Validators
的用法示例。
在下文中一共展示了Validators.pattern方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ngOnInit
ngOnInit() {
this.myForm = this._formBuilder.group({
'email': ['', Validators.required],
'password': ['', Validators.pattern('.{8,}')],
'confirmPassword': ['', Validators.compose([Validators.pattern('.{8,}')])]
});
}
示例2: constructor
constructor(fb: FormBuilder, changeDetector:ChangeDetectorRef) {
this.itemsArray = new ControlArray([]);
this.changeDetector = changeDetector;
this.invoiceForm = fb.group({
'customerName': ['', Validators.required],
'streetName': ['', Validators.required],
'postCode': ['', Validators.required],
'city': ['', Validators.required],
'email': ['', Validators.compose([Validators.required, Validators.pattern('.+@.+\..{0,10}')])],
'created': ['', Validators.compose([Validators.required, Validators.pattern('[0-9]{4}-[0-9]{2}-[0-9]{2}')])],
'due': ['', Validators.compose([Validators.required, Validators.pattern('[0-9]{4}-[0-9]{2}-[0-9]{2}')])],
'items': [],
});
}
示例3: addControlItem
private addControlItem() : void {
this.itemsArray.push(new ControlGroup({
description: new Control('', Validators.compose([Validators.required, Validators.maxLength(255)])),
amount: new Control('', Validators.compose([Validators.required, Validators.pattern('[0-9]{1,9}')])),
tax: new Control('', Validators.compose([Validators.required, Validators.pattern('[0-9]{1,2}')])),
price: new Control('', Validators.compose([Validators.required, Validators.pattern('[0-9]{1,7}(,[0-9]{2})?')]))
}));
}
示例4: constructor
constructor(
formBuilder: FormBuilder,
private _notificationService: NotificationsService
) {
this.regForm = formBuilder.group({
'name': ['', Validators.compose([Validators.required, Validators.minLength(3), Validators.maxLength(20), Validators.pattern('^[a-zA-Z ]+$')])],
'email': ['', Validators.compose([Validators.required, Validators.pattern('[0-9a-zA-Z_.-]+[@]+[a-zA-Z]+[.]+[a-zA-Z]{2,5}$')])],
'password': ['', Validators.compose([Validators.required, Validators.minLength(8), Validators.maxLength(1000), hasUpper, hasLower, hasDigit, hasSpecial])],
'employer': ['', Validators.pattern('^[a-zA-Z0-9 .]+$')],
'position': ['', Validators.pattern('^[a-zA-Z0-9 .]+$')],
'fruit': ['', Validators.pattern('^[a-zA-Z ]+$')],
'num': ['', Validators.pattern('^[0-9]+$')],
'year': ['', Validators.pattern('^([0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[1][0-9][0-9][0-9]|[2][0][0][0-9]|[2][0][1][0-6])$')],
'throne': ['', Validators.pattern('^[a-zA-Z0-9!._-]+[@]+[a-zA-Z.]+$')],
});
this.reqChecks = [
{name: 'name', value: this.regForm.find('name').valid},
{name: 'email', value: this.regForm.find('email').valid},
{name: 'password', value: this.regForm.find('password').valid}
];
this.optChecks = [
{name: 'employer', value: this.regForm.find('employer').valid},
{name: 'position', value: this.regForm.find('position').valid},
{name: 'fruit', value: this.regForm.find('fruit').valid},
{name: 'num', value: this.regForm.find('num').valid},
{name: 'year', value: this.regForm.find('year').valid},
{name: 'throne', value: this.regForm.find('throne').valid}
]
}
示例5: constructor
constructor(public nav: NavController, public fb: FormBuilder) {
this.recipeForm = fb.group({
"name": ["", Validators.compose([Validators.required, Validators.minLength(3)])],
"description": ["", Validators.compose([Validators.required, Validators.maxLength(140)])],
"prepTime": ["", Validators.compose([Validators.pattern("^[0-9]*$")])],
"cookingTime": ["", Validators.compose([Validators.required, Validators.pattern("^[0-9]*$")])],
"ingredient1": ["", Validators.compose([Validators.required])],
"direction1": ["", Validators.compose([Validators.required])]
});
this.ingredients = [];
this.name = this.recipeForm.controls["name"];
this.description = this.recipeForm.controls["description"];
this.prepTime = this.recipeForm.controls["prepTime"];
this.cookingTime = this.recipeForm.controls["cookingTime"];
this.ingredients = [
this.recipeForm.controls["ingredient1"]
];
this.directions = [
this.recipeForm.controls["direction1"]
];
}
示例6: initForm
private initForm() {
this.name = new Control('', Validators.compose([
Validators.required,
Validators.minLength(4),
]));
this.email = new Control('', Validators.compose([
Validators.required,
Validators.pattern(EMAIL_PATTERN),
]));
this.password = new Control('', Validators.compose([
Validators.required,
Validators.minLength(8),
]));
this.passwordConfirmation = new Control('', Validators.compose([
Validators.required,
AppValidators.match(this.password),
]));
this.myForm = new ControlGroup({
name: this.name,
email: this.email,
password: this.password,
passwordConfirmation: this.passwordConfirmation,
});
}
示例7: it
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"}});
});
示例8: expect
() => { expect(Validators.pattern("[a-zA-Z ]*")(new Control("aaAA"))).toEqual(null); });