當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript common.Validators類代碼示例

本文整理匯總了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;未經允許,請勿轉載。