本文整理匯總了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)]
})
}