本文整理汇总了TypeScript中angular2/common.Validators类的典型用法代码示例。如果您正苦于以下问题:TypeScript Validators类的具体用法?TypeScript Validators怎么用?TypeScript Validators使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Validators类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(fb: FormBuilder, private pass: PasswordService){
this.form = fb.group({
currentpass:['',Validators.compose([
Validators.required
]
)],
newpass:['', Validators.compose([
Validators.required,
Validators.minLength(5)
]
)],
confirmpass:['', Validators.compose([
Validators.required
])
]
},
{
validator: PasswordValidator.shouldBeEqual
})
}
示例2: constructor
constructor(private builder: FormBuilder) {
this.username = new Control(
"",
Validators.compose([Validators.required, UsernameValidator.startsWithNumber]),
UsernameValidator.usernameTaken
);
this.form = builder.group({
username: this.username
});
}
示例3: constructor
constructor(
fb: FormBuilder,
private _router: Router,
public globalValService:GlobalValService,
public authService: AuthService) {
this.signinForm = fb.group({
'email': ['', Validators.compose([
Validators.minLength(3),
Validators.maxLength(30),
Validators.required,
emailValidator
])],
'password': ['', Validators.required],
'captcha': ['', Validators.compose([
Validators.minLength(6),
Validators.maxLength(6),
Validators.required
])]
})
this.email = this.signinForm.controls['email']
this.password = this.signinForm.controls['password']
this.captcha = this.signinForm.controls['captcha']
this.globalValService.captchaUrlSubject.subscribe((captchaUrl:string) => {
this.captchaUrl = captchaUrl
})
this.authService.snsLoginsSubject.subscribe((logins:string[])=>{
this.logins = logins
})
}
示例4: constructor
constructor(fb: FormBuilder){
this.form = fb.group({
curr_passw: ['', Validators.compose(
[Validators.required,
PasswordValidators.cannotContainSpace,
]),
PasswordValidators.shouldBeUnique
],
new_password: ['', Validators.compose(
[Validators.required,
PasswordValidators.cannotContainSpace,
]),
PasswordValidators.shouldBeUnique
],
confirm_password: ['', Validators.compose(
[Validators.required,
PasswordValidators.cannotContainSpace,
]),
PasswordValidators.shouldBeUnique
]
}, {validator: PasswordValidators.shouldBeSame});
}
示例5: constructor
constructor(
formBuilder: FormBuilder,
authValidationService: AuthValidationService,
authService: AuthService,
router: Router) {
this._loginForm = formBuilder.group({
'email': [
'',
Validators.compose([
Validators.required,
authValidationService.emailValidator
])],
'password': [
'',
Validators.compose([
Validators.required
])]
});
this._authService = authService;
this._router = router;
}
示例6: ngOnInit
public ngOnInit() {
this.control = new Control(
"",
Validators.compose([
Validators.required,
this.keyFormatValidator,
this.keyTypeValidator.bind(this),
this.originMatchValidator.bind(this),
])
);
this.form.addControl("key", this.control);
}
示例7: constructor
constructor(fb: FormBuilder){
this.form = fb.group({
username: [
'',
Validators.compose([
Validators.required,
UsernameValidators.cannotContainSpace
]),
UsernameValidators.shouldBeUnique
],
password: ['', Validators.required]
});
}
示例8: constructor
constructor(fb: FormBuilder) { //good for big form
this.form1 = fb.group({
username:[
'default',
Validators.compose([
Validators.required,
UsernameValidators.cannotContainSpace
]),
UsernameValidators.shouldBeUnique
], //default value, validators, async validators
password: ['', Validators.required]
})
}
示例9: it
it("should collect errors from all the validators", fakeAsync(() => {
var c = Validators.composeAsync([
asyncValidator("expected", {"one": true}),
asyncValidator("expected", {"two": true})
]);
var value = null;
c(new Control("invalid")).then(v => value = v);
tick(1);
expect(value).toEqual({"one": true, "two": true});
}));
示例10: ngOnInit
ngOnInit(){
this.myForm = this._fb.group({
firstName: ['', Validators.required],
lastName: ['', Validators.required],
email: ['', Validators.compose([
Validators.required,
this.isEmail
])],
password: ['', Validators.required],
})
}