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


TypeScript Validators.pattern方法代码示例

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


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

示例1: ngOnInit

	ngOnInit() {
		this.myForm = this._formBuilder.group({
			'email': ['', Validators.required],
			'password': ['', Validators.pattern('.{8,}')],
			'confirmPassword': ['', Validators.compose([Validators.pattern('.{8,}')])]
		});
	}
开发者ID:LMApro,项目名称:ng2-sandbox,代码行数:7,代码来源:data-driven-form.component.ts

示例2: constructor

    constructor(fb: FormBuilder, changeDetector:ChangeDetectorRef) {
        this.itemsArray = new ControlArray([]);
        this.changeDetector = changeDetector;

        this.invoiceForm = fb.group({
            'customerName':  ['', Validators.required],
            'streetName':  ['', Validators.required],
            'postCode':  ['', Validators.required],
            'city':  ['', Validators.required],
            'email': ['', Validators.compose([Validators.required, Validators.pattern('.+@.+\..{0,10}')])],
            'created': ['', Validators.compose([Validators.required, Validators.pattern('[0-9]{4}-[0-9]{2}-[0-9]{2}')])],
            'due': ['', Validators.compose([Validators.required, Validators.pattern('[0-9]{4}-[0-9]{2}-[0-9]{2}')])],
            'items': [],
        });
    }
开发者ID:jakari,项目名称:invoicing,代码行数:15,代码来源:invoice-form.component.ts

示例3: addControlItem

 private addControlItem() : void {
     this.itemsArray.push(new ControlGroup({
         description: new Control('', Validators.compose([Validators.required, Validators.maxLength(255)])),
         amount: new Control('', Validators.compose([Validators.required, Validators.pattern('[0-9]{1,9}')])),
         tax: new Control('', Validators.compose([Validators.required, Validators.pattern('[0-9]{1,2}')])),
         price: new Control('', Validators.compose([Validators.required, Validators.pattern('[0-9]{1,7}(,[0-9]{2})?')]))
     }));
 }
开发者ID:jakari,项目名称:invoicing,代码行数:8,代码来源:invoice-form.component.ts

示例4: constructor

    constructor(
        formBuilder: FormBuilder,
        private _notificationService: NotificationsService
    ) {
        this.regForm = formBuilder.group({
            'name': ['', Validators.compose([Validators.required, Validators.minLength(3), Validators.maxLength(20), Validators.pattern('^[a-zA-Z ]+$')])],
            'email': ['', Validators.compose([Validators.required, Validators.pattern('[0-9a-zA-Z_.-]+[@]+[a-zA-Z]+[.]+[a-zA-Z]{2,5}$')])],
            'password': ['', Validators.compose([Validators.required, Validators.minLength(8), Validators.maxLength(1000), hasUpper, hasLower, hasDigit, hasSpecial])],
            'employer': ['', Validators.pattern('^[a-zA-Z0-9 .]+$')],
            'position': ['', Validators.pattern('^[a-zA-Z0-9 .]+$')],
            'fruit': ['', Validators.pattern('^[a-zA-Z ]+$')],
            'num': ['', Validators.pattern('^[0-9]+$')],
            'year': ['', Validators.pattern('^([0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[1][0-9][0-9][0-9]|[2][0][0][0-9]|[2][0][1][0-6])$')],
            'throne': ['', Validators.pattern('^[a-zA-Z0-9!._-]+[@]+[a-zA-Z.]+$')],
        });

        this.reqChecks = [
            {name: 'name', value: this.regForm.find('name').valid},
            {name: 'email', value: this.regForm.find('email').valid},
            {name: 'password', value: this.regForm.find('password').valid}
        ];

        this.optChecks = [
            {name: 'employer', value: this.regForm.find('employer').valid},
            {name: 'position', value: this.regForm.find('position').valid},
            {name: 'fruit', value: this.regForm.find('fruit').valid},
            {name: 'num', value: this.regForm.find('num').valid},
            {name: 'year', value: this.regForm.find('year').valid},
            {name: 'throne', value: this.regForm.find('throne').valid}
        ]
    }
开发者ID:flauc,项目名称:udacityMeetUpAngular2,代码行数:31,代码来源:reg.component.ts

示例5: constructor

  constructor(public nav: NavController, public fb: FormBuilder) {
    this.recipeForm = fb.group({
      "name": ["", Validators.compose([Validators.required, Validators.minLength(3)])],
      "description": ["", Validators.compose([Validators.required, Validators.maxLength(140)])],
      "prepTime": ["", Validators.compose([Validators.pattern("^[0-9]*$")])],
      "cookingTime": ["", Validators.compose([Validators.required, Validators.pattern("^[0-9]*$")])],
      "ingredient1": ["", Validators.compose([Validators.required])],
      "direction1": ["", Validators.compose([Validators.required])]
    });

    this.ingredients = [];

    this.name = this.recipeForm.controls["name"];
    this.description = this.recipeForm.controls["description"];
    this.prepTime = this.recipeForm.controls["prepTime"];
    this.cookingTime = this.recipeForm.controls["cookingTime"];
    this.ingredients = [
      this.recipeForm.controls["ingredient1"]
      ];
    this.directions = [
      this.recipeForm.controls["direction1"]
    ];
  }
开发者ID:vihanchaudhry,项目名称:pocket-recipes,代码行数:23,代码来源:new-recipe.ts

示例6: initForm

 private initForm() {
   this.name = new Control('', Validators.compose([
     Validators.required,
     Validators.minLength(4),
   ]));
   this.email = new Control('', Validators.compose([
     Validators.required,
     Validators.pattern(EMAIL_PATTERN),
   ]));
   this.password = new Control('', Validators.compose([
     Validators.required,
     Validators.minLength(8),
   ]));
   this.passwordConfirmation = new Control('', Validators.compose([
     Validators.required,
     AppValidators.match(this.password),
   ]));
   this.myForm = new ControlGroup({
     name: this.name,
     email: this.email,
     password: this.password,
     passwordConfirmation: this.passwordConfirmation,
   });
 }
开发者ID:gtostock,项目名称:angular2-app,代码行数:24,代码来源:SignupPage.ts

示例7: it

 it("should error on failure to match string", () => {
   expect(Validators.pattern("[a-zA-Z ]*")(new Control("aaa0")))
       .toEqual({"pattern": {"requiredPattern": "^[a-zA-Z ]*$", "actualValue": "aaa0"}});
 });
开发者ID:DarshanKumar89,项目名称:angular,代码行数:4,代码来源:validators_spec.ts

示例8: expect

 () => { expect(Validators.pattern("[a-zA-Z ]*")(new Control("aaAA"))).toEqual(null); });
开发者ID:DarshanKumar89,项目名称:angular,代码行数:1,代码来源:validators_spec.ts


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