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


TypeScript Validators.pattern方法代码示例

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


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

示例1: ngOnInit

 ngOnInit() {
     this.userForm = this.formBuilder.group({
         userId: [
             'dfbaskin',
             Validators.compose([
                 Validators.required,
                 Validators.pattern('^[a-z]([a-z0-9_])+$')
             ])
         ],
         fullName: [
             'Dave F. Baskin',
             Validators.required
         ],
         contact: this.formBuilder.group({
             emailAddr: [
                 'dfbaskin@gmail.com',
                 Validators.required
             ],
             twitterHandle: [
                 '@dfbaskin',
                 Validators.pattern('^\@[a-z]([a-z0-9_])+$')
             ],
         })
     });
 }
开发者ID:dfbaskin,项目名称:angular2-overview,代码行数:25,代码来源:model-forms-example.ts

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

示例3: constructor

constructor(private _routeParams: RouteParams,                 
                 private UrlSession: SessionUrlHandler,
                 private prof:SessionProfileHandler,
                 public toastr: ToastsManager,
                 builder: FormBuilder) { 
        this.basicinfoForm = builder.group({
            displayname: ["", Validators.required],
            currentProfession: ["", Validators.required],
            address: ["", Validators.required],
            contryCode: ["", Validators.compose([Validators.required, Validators.pattern('\d+')])],
            phoneNumber: ["", Validators.compose([Validators.required, Validators.pattern('\d+')])],
            emailAddress: ["", Validators.compose([Validators.required, this.emailValidator])],
            dob: ["", Validators.required],
        });
    }
开发者ID:prakashsam,项目名称:infoworld,代码行数:15,代码来源:base.info.component.ts

示例4: constructor

 constructor(private eventService: EventService, 
     private builder: FormBuilder, private router: Router) {
   this.name = new Control('', Validators.required);
   this.date = new Control('', Validators.required);
   this.time = new Control('', Validators.required);
   this.price = new Control('', Validators.compose([Validators.required, Validators.pattern('\\d\+(\\.\\d{0,2})?')]));
   this.address = new Control('', Validators.required);
   this.city = new Control('', Validators.required);
   this.country = new Control('', Validators.compose([Validators.required, Validators.pattern('[A-Z]{2}')]));
   this.imageUrl = new Control('', Validators.required);
   // this.country = new Control('', exactly2);
   
   this.newEventForm = builder.group({
     name: this.name,
     date: this.date,
     time: this.time,
     price: this.price,
     location: builder.group({
       address: this.address,
       city: this.city,
       country: this.country
     }),
     imageUrl: this.imageUrl,
   })
 }
开发者ID:joeeames,项目名称:ng2-fundamentals-demo,代码行数:25,代码来源:create-event.component.ts

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

示例6: constructor

 constructor(formBuilder: FormBuilder) {
   this.form = formBuilder.group({
     name: ['', Validators.compose([
       Validators.required,
       Validators.minLength(2),
       Validators.pattern('[A-Za-z]+')
     ])]
   });
 }
开发者ID:tb,项目名称:ng2-formsy,代码行数:9,代码来源:validations.form.ts

示例7: constructor

 constructor(
     private typerService: TyperService,
     private formBuilder: FormBuilder,
     private valid: boolean
 ){
     this.personForm = formBuilder.group({
         name: ["", Validators.required],
         lastname: ["", Validators.required],
         email: ["", Validators.required, Validators.pattern("[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$")]
     });
     this.valid = this.personForm.value
 }
开发者ID:hernan91,项目名称:ww3,代码行数:12,代码来源:contact-info-modify.component.ts

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

示例9: constructor

  constructor(private store: Store<any>, private router: Router, private signupService: SignupService, private builder: FormBuilder) {

    this.firstName = new Control('', Validators.compose([Validators.required, Validators.minLength(2)]));
    this.lastName = new Control('');
    this.email = new Control('', Validators.compose([Validators.required, Validators.pattern(EMAIL_REGEX_PATTERN)]));
    this.login = this.email;
    this.password = new Control('', Validators.compose([Validators.required, Validators.minLength(8)]));

    this.signupForm = builder.group({
      login: this.login,
      firstName: this.firstName,
      lastName: this.lastName,
      email: this.email,
      password: this.password
    });
    this.signupInfo = this.store.select('signup');
  }
开发者ID:mmrath,项目名称:angular2-webpack-clone,代码行数:17,代码来源:signup.component.ts

示例10: elementToControl

    elementToControl(element:ElementBase<any>):Control {
        let syncValidators = [];

        //Standard syncValidators
        if (element.required) {
            syncValidators.push(Validators.required);
        }

        if (element.patternMatch) {
            syncValidators.push(Validators.pattern(element.patternMatch))
        }

        if (element.minLength) {
            syncValidators.push(Validators.minLength(element.minLength))
        }

        if (element.maxLength) {
            syncValidators.push(Validators.maxLength(element.maxLength))
        }

        let asyncValidators = [];
        //Add async validation
        if (element.customValidExistance) {
            if (element.key === 'email') {
                asyncValidators.push(UserExistenceValidator.checkEmail);
            }

            if (element.key === 'displayName') {
                asyncValidators.push(UserExistenceValidator.checkUsername);
            }
        }

        return new Control(element.value || '',
            Validators.compose(syncValidators),
            Validators.composeAsync(asyncValidators));

    }
开发者ID:Elf2707,项目名称:StylePrj,代码行数:37,代码来源:element-control.services.ts


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