本文整理汇总了TypeScript中@angular/common.Validators类的典型用法代码示例。如果您正苦于以下问题:TypeScript Validators类的具体用法?TypeScript Validators怎么用?TypeScript Validators使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Validators类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: 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);
}
}
开发者ID:kdsbatra,项目名称:angular2-easy-forms,代码行数:12,代码来源:control-group.service.ts
示例2: constructor
constructor(
private _userService: UserService,
private _navController: Nav,
private _formBuilder: FormBuilder) {
this.passwordForm = this._formBuilder.group({
'oldPassword': ['', Validators.required],
matchingPassword: this._formBuilder.group({
password: ['', Validators.compose([Validators.required, ValidationService.passwordValidator])],
confirmPassword: ['', Validators.compose([Validators.required])]
}, { validator: this.checkPasswords })
});
}
开发者ID:marenwoodruff,项目名称:m2,代码行数:12,代码来源:changePassword.component.ts
示例3: constructor
constructor(fb: FormBuilder) {
this.changePassForm = fb.group({
oldpass: ['', Validators.compose([
Validators.required,
OldPassMatchValidators.needToBe,
])],
npass: ['', Validators.compose([
Validators.required,
Validators.minLength(5),
])],
confirmpass: ['', Validators.required ]
},{ validator: NotMatchValidators.needToMatch });
}
开发者ID:Nordnat,项目名称:angular2udemy,代码行数:13,代码来源:change-pass.component.ts
示例4: constructor
constructor(fb: FormBuilder) {
this.form = fb.group({
current: ['', Validators.compose([
Validators.required,
CustomValidators.minimumLength
])],
new: ['', Validators.compose([
Validators.required,
CustomValidators.minimumLength
])],
confirm: ['', Validators.required]
}, { validator: CustomValidators.passwordMatch});
}
开发者ID:clintlosee,项目名称:angular2-course,代码行数:13,代码来源:password-change.component.ts
示例5: constructor
constructor(private fb: FormBuilder, private userService: UserService, private router: Router) {
// Create the username form control
this.username = fb.control('', Validators.compose([Validators.required, Validators.minLength(3)]));
this.username.valueChanges.subscribe((newValue) => { this.usernameErrorMessage = ''; });
// Create the password form control
this.password = fb.control('', Validators.compose([Validators.required]));
this.password.valueChanges.subscribe((newValue) => { this.passwordErrorMessage = ''; });
// Create the group
this.userForm = fb.group({ username: this.username, password: this.password });
}
开发者ID:mco67,项目名称:myWayWeb,代码行数:13,代码来源:login-page.component.ts
示例6: constructor
constructor(
private _userService: UserService,
private _navController: Nav,
private _formBuilder: FormBuilder,
private _authService: AuthorizationService) {
this.userForm = this._formBuilder.group({
'email': ['', Validators.compose([ValidationService.emailValidator, Validators.required])],
'name': ['', Validators.required],
'company': [''],
'jobTitle': [''],
'phone': ['', Validators.compose([ValidationService.phoneNumberValidator])]
})
}
开发者ID:marenwoodruff,项目名称:m2,代码行数:13,代码来源:user-settings.component.ts
示例7: 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
]))
});
}
开发者ID:RunningV,项目名称:angular2-rc,代码行数:13,代码来源:form-model.component.ts
示例8: constructor
constructor(builder: FormBuilder) {
this.email = new Control('',
Validators.compose([Validators.required, CustomValidators.emailFormat])
);
this.password = new Control('',
Validators.compose([Validators.required, Validators.minLength(4)])
);
this.group = builder.group({
email: this.email,
password: this.password
});
}
开发者ID:andyglick,项目名称:ngCourse2,代码行数:14,代码来源:my-form.component.ts
示例9: _applyValidators
private _applyValidators() {
this.form = this._formBuilder.group({
name: ['', Validators.compose([
Validators.required
])],
email: ['', Validators.compose([
Validators.required,
NbValidators.email
]), NbValidators.unique(this._emailService, this._routeParams.get('id'))],
birthday: ['', Validators.compose([
NbValidators.date
])]
})
}
开发者ID:emesonsantana,项目名称:bmp1-web-service,代码行数:14,代码来源:edit.component.ts
示例10: constructor
constructor(
public platform: Platform,
public nav: NavController,
public authData: AuthData,
public formBuilder: FormBuilder
) {
this.nav = nav;
this.authData = authData;
this.loginForm = formBuilder.group({
email: ['', Validators.required, Validators.minLength(6), Validators.maxLength(64)],
password: ['', Validators.required, Validators.minLength(6), Validators.maxLength(24)]
})
}
开发者ID:EliuFlorez,项目名称:app-picture,代码行数:14,代码来源:login.ts
注:本文中的@angular/common.Validators类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论