本文整理汇总了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);
}
}
示例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 })
});
}
示例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 });
}
示例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});
}
示例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 });
}
示例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])]
})
}
示例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
]))
});
}
示例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
});
}
示例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
])]
})
}
示例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)]
})
}