本文整理汇总了TypeScript中@angular/common.Validators.pattern方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Validators.pattern方法的具体用法?TypeScript Validators.pattern怎么用?TypeScript Validators.pattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/common.Validators
的用法示例。
在下文中一共展示了Validators.pattern方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ngOnInit
ngOnInit() {
this.userForm = this.formBuilder.group({
userId: [
'dfbaskin',
Validators.compose([
Validators.required,
Validators.pattern('^[a-z]([a-z0-9_])+$')
])
],
fullName: [
'Dave F. Baskin',
Validators.required
],
contact: this.formBuilder.group({
emailAddr: [
'dfbaskin@gmail.com',
Validators.required
],
twitterHandle: [
'@dfbaskin',
Validators.pattern('^\@[a-z]([a-z0-9_])+$')
],
})
});
}
示例2: ngOnInit
ngOnInit() {
this.myForm = new ControlGroup({
name: new Control('', Validators.required),
street: new Control('', Validators.minLength(3)),
email: new Control('',
Validators.pattern('^[A-Za-z0-9]+\@[A-Za-z0-9]+[.][A-Za-z0-9]{2,5}')),
city: new Control('', Validators.maxLength(10)),
zip: new Control('', Validators.compose([
Validators.pattern('[A-Za-z]{5}'),
Validators.required
]))
});
}
示例3: constructor
constructor(private _routeParams: RouteParams,
private UrlSession: SessionUrlHandler,
private prof:SessionProfileHandler,
public toastr: ToastsManager,
builder: FormBuilder) {
this.basicinfoForm = builder.group({
displayname: ["", Validators.required],
currentProfession: ["", Validators.required],
address: ["", Validators.required],
contryCode: ["", Validators.compose([Validators.required, Validators.pattern('\d+')])],
phoneNumber: ["", Validators.compose([Validators.required, Validators.pattern('\d+')])],
emailAddress: ["", Validators.compose([Validators.required, this.emailValidator])],
dob: ["", Validators.required],
});
}
示例4: constructor
constructor(private eventService: EventService,
private builder: FormBuilder, private router: Router) {
this.name = new Control('', Validators.required);
this.date = new Control('', Validators.required);
this.time = new Control('', Validators.required);
this.price = new Control('', Validators.compose([Validators.required, Validators.pattern('\\d\+(\\.\\d{0,2})?')]));
this.address = new Control('', Validators.required);
this.city = new Control('', Validators.required);
this.country = new Control('', Validators.compose([Validators.required, Validators.pattern('[A-Z]{2}')]));
this.imageUrl = new Control('', Validators.required);
// this.country = new Control('', exactly2);
this.newEventForm = builder.group({
name: this.name,
date: this.date,
time: this.time,
price: this.price,
location: builder.group({
address: this.address,
city: this.city,
country: this.country
}),
imageUrl: this.imageUrl,
})
}
示例5: constructor
constructor(
private events: Events,
private nav: NavController,
private auth: AuthProvider,
private formBuilder: FormBuilder) {
this.name = new Control("", Validators.compose([
Validators.required,
Validators.minLength(6),
Validators.maxLength(64)
]));
this.email = new Control("", Validators.compose([
Validators.required,
Validators.pattern("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$"),
Validators.minLength(6),
Validators.maxLength(64)
]));
this.password = new Control("", Validators.compose([
Validators.required,
Validators.minLength(6),
Validators.maxLength(24)
]));
this.registerForm = formBuilder.group({
"name": this.name,
"email": this.email,
"password": this.password
});
}
示例6: constructor
constructor(formBuilder: FormBuilder) {
this.form = formBuilder.group({
name: ['', Validators.compose([
Validators.required,
Validators.minLength(2),
Validators.pattern('[A-Za-z]+')
])]
});
}
示例7: constructor
constructor(
private typerService: TyperService,
private formBuilder: FormBuilder,
private valid: boolean
){
this.personForm = formBuilder.group({
name: ["", Validators.required],
lastname: ["", Validators.required],
email: ["", Validators.required, Validators.pattern("[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$")]
});
this.valid = this.personForm.value
}
示例8: setValidator
function setValidator(item: Validation, original?) {
switch (item.type) {
case 'required': return Validators.required;
case 'minLength': return Validators.minLength(item.value);
case 'maxLength': return Validators.maxLength(item.value);
case 'pattern': return Validators.pattern(item.value);
case 'custom': return item.value;
case 'match':
matches.push({toMatch: item.value, model: original.key});
return CustomValidators.match(item.value);
}
}
示例9: constructor
constructor(private store: Store<any>, private router: Router, private signupService: SignupService, private builder: FormBuilder) {
this.firstName = new Control('', Validators.compose([Validators.required, Validators.minLength(2)]));
this.lastName = new Control('');
this.email = new Control('', Validators.compose([Validators.required, Validators.pattern(EMAIL_REGEX_PATTERN)]));
this.login = this.email;
this.password = new Control('', Validators.compose([Validators.required, Validators.minLength(8)]));
this.signupForm = builder.group({
login: this.login,
firstName: this.firstName,
lastName: this.lastName,
email: this.email,
password: this.password
});
this.signupInfo = this.store.select('signup');
}
示例10: elementToControl
elementToControl(element:ElementBase<any>):Control {
let syncValidators = [];
//Standard syncValidators
if (element.required) {
syncValidators.push(Validators.required);
}
if (element.patternMatch) {
syncValidators.push(Validators.pattern(element.patternMatch))
}
if (element.minLength) {
syncValidators.push(Validators.minLength(element.minLength))
}
if (element.maxLength) {
syncValidators.push(Validators.maxLength(element.maxLength))
}
let asyncValidators = [];
//Add async validation
if (element.customValidExistance) {
if (element.key === 'email') {
asyncValidators.push(UserExistenceValidator.checkEmail);
}
if (element.key === 'displayName') {
asyncValidators.push(UserExistenceValidator.checkUsername);
}
}
return new Control(element.value || '',
Validators.compose(syncValidators),
Validators.composeAsync(asyncValidators));
}