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


TypeScript common.Validators類代碼示例

本文整理匯總了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
     })
 }
開發者ID:cristianmurillo87,項目名稱:cursoAngular2,代碼行數:21,代碼來源:password.component.ts

示例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
		});
	}	
開發者ID:TitoAgudelo,項目名稱:angular2-form-validation-example,代碼行數:12,代碼來源:app.ts

示例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
		})
	}
開發者ID:KennyLisc,項目名稱:jackblog-angular2,代碼行數:29,代碼來源:index.ts

示例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});
 }
開發者ID:fscbest,項目名稱:angular2-seed,代碼行數:22,代碼來源:change_passw-form.component.ts

示例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;
    }
開發者ID:GazousGit,項目名稱:Angular2-struct,代碼行數:22,代碼來源:login-form.component.ts

示例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);
    }
開發者ID:davidwrede,項目名稱:habitat,代碼行數:13,代碼來源:KeyAddFormComponent.ts

示例7: constructor

 constructor(fb: FormBuilder){
     this.form = fb.group({
         username: [
             '',
             Validators.compose([
                 Validators.required,
                 UsernameValidators.cannotContainSpace
             ]),
             UsernameValidators.shouldBeUnique
         ],
         password: ['', Validators.required]
     });
 }
開發者ID:briveramelo,項目名稱:angular2demo,代碼行數:13,代碼來源:signup-form.component.ts

示例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]
   })
 }
開發者ID:valmassoi,項目名稱:udemy-angular-2-tutorial,代碼行數:13,代碼來源:signup-form.component.ts

示例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});
         }));
開發者ID:Ashok-Pal,項目名稱:angular,代碼行數:13,代碼來源:validators_spec.ts

示例10: ngOnInit

 ngOnInit(){
     this.myForm = this._fb.group({
         firstName: ['', Validators.required],
         lastName: ['', Validators.required],
         email: ['', Validators.compose([
             Validators.required,
             this.isEmail
         ])],
         password: ['', Validators.required],
     })
     
     
 }
開發者ID:gratawa,項目名稱:udmMessages,代碼行數:13,代碼來源:signup.component.ts


注:本文中的angular2/common.Validators類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。