当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Validators.maxLength方法代码示例

本文整理汇总了TypeScript中@angular/common.Validators.maxLength方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Validators.maxLength方法的具体用法?TypeScript Validators.maxLength怎么用?TypeScript Validators.maxLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/common.Validators的用法示例。


在下文中一共展示了Validators.maxLength方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

    constructor(
        private events: Events,
        private nav: NavController,
        private auth: AuthProvider,
        private formBuilder: FormBuilder) {

        this.name = new Control("", Validators.compose([
            Validators.required,
            Validators.minLength(6),
            Validators.maxLength(64)
        ]));
        this.email = new Control("", Validators.compose([
            Validators.required,
            Validators.pattern("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$"),
            Validators.minLength(6),
            Validators.maxLength(64)
        ]));
        this.password = new Control("", Validators.compose([
            Validators.required,
            Validators.minLength(6),
            Validators.maxLength(24)
        ]));

        this.registerForm = formBuilder.group({
            "name": this.name,
            "email": this.email,
            "password": this.password
        });
    }
开发者ID:isman-usoh,项目名称:followork,代码行数:29,代码来源:register.ts

示例2: ngOnInit

    ngOnInit() {

        this.ctrlEmail = new Control('', Validators.compose([Validators.required, Validators.pattern("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}$")]));

        this.ctrlPassword = new Control('', Validators.compose([
            Validators.required, Validators.minLength(8), Validators.maxLength(255),
        ]));

        this.ctrlRegPassword = new Control('', Validators.compose([
            Validators.required,
            Validators.minLength(8),
            Validators.maxLength(255),
        ]));

        this.ctrlRegPasswordConfirm = new Control('', (password:AbstractControl) => {
            return password.value != this.ctrlRegPassword.value ? {passwordConfirmation: 'Password confirmation does not match'} : null;
        });


        this.loginForm = new ControlGroup({
            password: this.ctrlPassword,
            email: this.ctrlEmail
        });

        this.registerForm = new ControlGroup({
            email: this.ctrlEmail,
            password: this.ctrlRegPassword,
            passwordConfirm: this.ctrlRegPasswordConfirm
        });

        this.isLogin = true;

        this.wrongEmailPassword = false;

        this.regEmailConflict = false;

        this.otherErrorLogin = false;

        // redirect to the previous page if user is logged in
        this._authContext.observable().subscribe(
            (authContext:AuthContext) => {
                if (authContext.isLoggedIn()) {
                    this.goBack();
                }
            }
        );

        if (this._authContext.isLoggedIn()) {
            this.goBack();
        }
    }
开发者ID:mducnguyen,项目名称:TicklrClient,代码行数:51,代码来源:auth.component.ts

示例3: 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

示例4: ngOnInit

 ngOnInit() { 
     
     this.name = new Control('',
         Validators.compose([
             Validators.required
         ]));
         
      this.price = new Control('',
         Validators.compose([
             Validators.required
         ]));
         
      this.description = new Control('',
         Validators.compose([
             Validators.required,
             Validators.minLength(3),
             Validators.maxLength(50)
         ]));
         
      this.insertForm = this._fb.group({
          'name': this.name,
          'price': this.price,
          'description': this.description
      });
     
 }
开发者ID:jmdagenais,项目名称:angular2DemoApp,代码行数:26,代码来源:product-insert.component.ts

示例5: initValidators

 private initValidators():void {
     console.log('Adding validators to control ',this.name);
     let validators:Array<Function> = [];
     if(this.required) {
         validators.push(Validators.required);
     }
     if(this.isTypeText() && this.minLength) {
         console.log('Adding minLength validator',this.minLength);
         validators.push(Validators.minLength(this.minLength));
     }
     if(this.isTypeText() && this.maxLength) {
         console.log('Adding maxLength validator',this.maxLength);
         validators.push(Validators.maxLength(this.maxLength));
     }
     if(this.isTypeEmail()) {
         validators.push(ValidatorService.emailValidator);
     }
     if(this.isTypeNumber()) {
         validators.push(ValidatorService.numberValidator);
     }
     if(this.isInput() && this.pattern) {
         validators.push(ValidatorService.regexValidator(this.pattern));
     }
     console.log(validators.length+' validators added to control',this.name);
     this.validators = Validators.compose(validators);
 }
开发者ID:billirg,项目名称:angular-spring-dynamic-form,代码行数:26,代码来源:form.ts

示例6: constructor

 constructor(fb: FormBuilder) {
   this.projectForm = fb.group({
     'clientName': ['', Validators.required],
     'description': ['Nuclear Missile Defense System', Validators.compose([
       Validators.required,
       Validators.maxLength(30)
     ])],
     'clientEmail': ['', Validators.compose([
       MdPatternValidator.inline('^.+@.+\..+$'),
       Validators.required,
       Validators.minLength(10),
       Validators.maxLength(100)
     ])],
     'rate': [500, Validators.compose([
       MdNumberRequiredValidator.inline(),
       MdPatternValidator.inline('^1234$'),
       MdMinValueValidator.inline(800),
       MdMaxValueValidator.inline(4999)
     ])]
   });
 }
开发者ID:robwafle,项目名称:ng2-material,代码行数:21,代码来源:form_builder.ts

示例7: 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

示例8: 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

示例9: formValid

    formValid(): void {
        this.nameControl = new Control('', Validators.compose([Validators.required,
                                                                Validators.minLength(3),
                                                                Validators.maxLength(50)]));
        this.editForm = this._fb.group({
            'name': this.nameControl,
            'price': ['', Validators.compose([
                        NumberValidator.isAValidateNumber(),
                        Validators.required
                    ])],
            'imageUrl': ['',
                    Validators.compose([Validators.required,
                    Validators.minLength(5),
                    Validators.maxLength(250)])],
            'starRating': ['',
                    NumberValidator.range(1, 5)],
            'desc': ['']
        });

        this.editForm.valueChanges
            .subscribe(data => this.onValueChanged(data));
    }
开发者ID:IVictorFeng,项目名称:fish-store,代码行数:22,代码来源:form-validation.ts

示例10: constructor

    /**
     * RoomDetail Constructor.
     * @param _router
     * @param _routeParams
     * @param _roomService
     * @param builder
     */
    constructor(private _router:Router,
                private _routeParams:RouteParams,
                private _roomService:RoomService,
                private builder: FormBuilder) {
        // Add validators to input field
        this.message = new Control('', Validators.compose([
            Validators.required,
            Validators.minLength(1),
            Validators.maxLength(150)
        ]));

        // Create a form from input field
        this.messageForm = builder.group({
            message: this.message
        });
    }
开发者ID:riblee,项目名称:chat-client,代码行数:23,代码来源:roomDetail.component.ts


注:本文中的@angular/common.Validators.maxLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。