本文整理汇总了TypeScript中@angular/forms.Validators.pattern方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Validators.pattern方法的具体用法?TypeScript Validators.pattern怎么用?TypeScript Validators.pattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/forms.Validators
的用法示例。
在下文中一共展示了Validators.pattern方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(
private router: Router,
private formBuilder: FormBuilder,
private commonService: CommonService,
private accountService: AccountService
){
// Initialize instance variables
this.isButtonActive = false;
this.loginForm = this.formBuilder.group({
email: [
'',
[
Validators.required,
Validators.pattern(this.commonService.getRGXEmail())
]
],
password: [
'',
[
Validators.required,
Validators.pattern(this.commonService.getRGXPassword())
]
]
});
}
示例2: ngOnInit
ngOnInit() {
this.categoriesObs = this.ds.categories;
this.vehiculeForm = this.fb.group({
immatriculation: [
'',
[
Validators.required,
Validators.pattern(/^[A-Z][A-Z]-\d\d\d-[A-Z][A-Z]$/)
]
],
marque: ['', Validators.required],
modele: ['', Validators.required],
categorie: ['', Validators.required],
nbPlaces: [
'',
[
Validators.required,
Validators.max(20),
Validators.min(1),
Validators.pattern(/^\d+$/)
]
],
photo: ['', Validators.required]
});
}
示例3: decimalNumber
/**
* Validator function in order to validate decimal numbers.
* @returns {ValidatorFn} A validator function that returns an error map containing `pattern`
* if the validation failed, otherwise `null`.
*/
static decimalNumber(allowsNegative: boolean = true): ValidatorFn {
if (allowsNegative) {
return Validators.pattern(/^-?[0-9]+(.[0-9]+)?$/i);
} else {
return Validators.pattern(/^[0-9]+(.[0-9]+)?$/i);
}
}
示例4: ngOnInit
ngOnInit() {
this.user = new User;
this.form = new FormGroup({
'name': new FormControl('', [Validators.pattern(this.getValidator('Username')), Validators.required]),
'password': new FormControl('', [Validators.pattern(this.getValidator('Password')), Validators.required]),
'email': new FormControl('', [Validators.pattern(this.getValidator('Email')), Validators.required])
});
}
示例5: createForm
createForm(){
this.registerForm = this.fb.group({
username : ['', [Validators.required, Validators.pattern("^[a-zA-Z0-9_-]{4,20}$")]],
firstname: ['', [Validators.required, Validators.pattern("^[a-zA-Z- ]{3,30}$")]],
lastname: ['', [Validators.required, Validators.pattern("^[a-zA-Z- ]{3,30}$")]],
email: ['',[Validators.required, Validators.email]]
})
}
示例6: ngOnInit
ngOnInit() {
this.personalInfoForm = this.formBuilder.group(
{
name: ['', [Validators.required, Validators.pattern(/[a-zA-Z].*/)]],
surname: ['', [Validators.required, Validators.pattern(/[a-zA-Z].*/)]],
age: ['', [Validators.required, Validators.min(1),Validators.max(99)]],
})
}
示例7: constructor
constructor (private i18n: I18n) {
this.INSTANCE_NAME = {
VALIDATORS: [ Validators.required ],
MESSAGES: {
'required': this.i18n('Instance name is required.')
}
}
this.INSTANCE_SHORT_DESCRIPTION = {
VALIDATORS: [ Validators.max(250) ],
MESSAGES: {
'max': this.i18n('Short description should not be longer than 250 characters.')
}
}
this.SERVICES_TWITTER_USERNAME = {
VALIDATORS: [ Validators.required ],
MESSAGES: {
'required': this.i18n('Twitter username is required.')
}
}
this.CACHE_PREVIEWS_SIZE = {
VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
MESSAGES: {
'required': this.i18n('Previews cache size is required.'),
'min': this.i18n('Previews cache size must be greater than 1.'),
'pattern': this.i18n('Previews cache size must be a number.')
}
}
this.SIGNUP_LIMIT = {
VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
MESSAGES: {
'required': this.i18n('Signup limit is required.'),
'min': this.i18n('Signup limit must be greater than 1.'),
'pattern': this.i18n('Signup limit must be a number.')
}
}
this.ADMIN_EMAIL = {
VALIDATORS: [ Validators.required, Validators.email ],
MESSAGES: {
'required': this.i18n('Admin email is required.'),
'email': this.i18n('Admin email must be valid.')
}
}
this.TRANSCODING_THREADS = {
VALIDATORS: [ Validators.required, Validators.min(1) ],
MESSAGES: {
'required': this.i18n('Transcoding threads is required.'),
'min': this.i18n('Transcoding threads must be greater than 1.')
}
}
}
示例8: ngOnInit
ngOnInit() {
this.resetForm = this._fb.group(
{
password: ['', Validators.compose([Validators.required, Validators.pattern(passwordRegexp)])],
confirm_password: ['', Validators.compose([Validators.required, Validators.pattern(passwordRegexp)])],
},
{
validator: matchingPasswords('password', 'confirm_password')
}
);
this._route.params.subscribe(params => {this._token = params['id']});
}
示例9: constructor
constructor( vcr: ViewContainerRef, private _sharedData: SharedDataService, private _activatedRoute: ActivatedRoute, private _langService: LanguageService, private _authService: AuthService, private _router: Router, fb: FormBuilder) {
this.loginForm = fb.group({
'email' : [null, Validators.compose([Validators.required, Validators.pattern('[^ @]*@[^ @]*')])],
'password' : [null, Validators.compose([Validators.required, Validators.pattern('^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$')])]
});
this._langService.loadLanguage().subscribe(response => {
this.language = response.pcprepkit.login;
this.header = response.pcprepkit.common.header;
this.authMessages = response.pcprepkit.authMessages;
});
this.pcprepkitlogo = '../../assets/img/prepkitlogo.png';
}
示例10: ngOnInit
ngOnInit() {
this.loadEmail = true;
this.isLogin = true;
this.loginForm = this.fb.group({
'email': [null, Validators.compose([Validators.required, Validators.pattern('^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$')])],
'password': [null, Validators.compose([Validators.required])]
});
this.loginRecover = this.fb.group({
'emailRecover': [null, Validators.compose([Validators.required, Validators.pattern('^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$')])],
});
}