当前位置: 首页>>代码示例>>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;未经允许,请勿转载。