當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。