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


TypeScript Validators.pattern方法代码示例

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


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

示例1: constructor

 constructor(
     private router: Router,
     private formBuilder: FormBuilder,
     private commonService: CommonService,
     private accountService: AccountService
 ){
     // Initialize instance variables
     this.isButtonActive = false;
     this.loginForm = this.formBuilder.group({
         email: [
             '',
             [
                 Validators.required,
                 Validators.pattern(this.commonService.getRGXEmail())
             ]
         ],
         password: [
             '',
             [
                 Validators.required,
                 Validators.pattern(this.commonService.getRGXPassword())
             ]
         ]
     });
 }
开发者ID:skoocda,项目名称:spreza,代码行数:25,代码来源:login.ts

示例2: ngOnInit

  ngOnInit() {
    this.categoriesObs = this.ds.categories;

    this.vehiculeForm = this.fb.group({
      immatriculation: [
        '',
        [
          Validators.required,
          Validators.pattern(/^[A-Z][A-Z]-\d\d\d-[A-Z][A-Z]$/)
        ]
      ],
      marque: ['', Validators.required],
      modele: ['', Validators.required],
      categorie: ['', Validators.required],
      nbPlaces: [
        '',
        [
          Validators.required,
          Validators.max(20),
          Validators.min(1),
          Validators.pattern(/^\d+$/)
        ]
      ],
      photo: ['', Validators.required]
    });
  }
开发者ID:thienban,项目名称:gestion-du-transport,代码行数:26,代码来源:creer-vehicule.component.ts

示例3: decimalNumber

 /**
  * Validator function in order to validate decimal numbers.
  * @returns {ValidatorFn} A validator function that returns an error map containing `pattern`
  * if the validation failed, otherwise `null`.
  */
 static decimalNumber(allowsNegative: boolean = true): ValidatorFn {
   if (allowsNegative) {
     return Validators.pattern(/^-?[0-9]+(.[0-9]+)?$/i);
   } else {
     return Validators.pattern(/^[0-9]+(.[0-9]+)?$/i);
   }
 }
开发者ID:IlsooByun,项目名称:ceph,代码行数:12,代码来源:cd-validators.ts

示例4: ngOnInit

 ngOnInit() {
   this.user = new User;
   this.form = new FormGroup({
     'name': new FormControl('', [Validators.pattern(this.getValidator('Username')), Validators.required]),
     'password': new FormControl('', [Validators.pattern(this.getValidator('Password')), Validators.required]),
     'email': new FormControl('', [Validators.pattern(this.getValidator('Email')), Validators.required])
   });
 }
开发者ID:WindHub,项目名称:pi-ng,代码行数:8,代码来源:register.component.ts

示例5: createForm

 createForm(){
   this.registerForm = this.fb.group({
     username : ['', [Validators.required, Validators.pattern("^[a-zA-Z0-9_-]{4,20}$")]],
     firstname: ['', [Validators.required, Validators.pattern("^[a-zA-Z- ]{3,30}$")]],
     lastname: ['', [Validators.required, Validators.pattern("^[a-zA-Z- ]{3,30}$")]],
     email: ['',[Validators.required, Validators.email]]
   })
 }
开发者ID:idot,项目名称:betterplay,代码行数:8,代码来源:register-user.component.ts

示例6: ngOnInit

  ngOnInit() {
    this.personalInfoForm = this.formBuilder.group(

      {
        name: ['', [Validators.required, Validators.pattern(/[a-zA-Z].*/)]],
        surname: ['', [Validators.required, Validators.pattern(/[a-zA-Z].*/)]],
        age: ['', [Validators.required, Validators.min(1),Validators.max(99)]],
      })
  }
开发者ID:michaelmoney,项目名称:Angular-self-development,代码行数:9,代码来源:form.component.ts

示例7: constructor

  constructor (private i18n: I18n) {
    this.INSTANCE_NAME = {
      VALIDATORS: [ Validators.required ],
      MESSAGES: {
        'required': this.i18n('Instance name is required.')
      }
    }

    this.INSTANCE_SHORT_DESCRIPTION = {
      VALIDATORS: [ Validators.max(250) ],
      MESSAGES: {
        'max': this.i18n('Short description should not be longer than 250 characters.')
      }
    }

    this.SERVICES_TWITTER_USERNAME = {
      VALIDATORS: [ Validators.required ],
      MESSAGES: {
        'required': this.i18n('Twitter username is required.')
      }
    }

    this.CACHE_PREVIEWS_SIZE = {
      VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
      MESSAGES: {
        'required': this.i18n('Previews cache size is required.'),
        'min': this.i18n('Previews cache size must be greater than 1.'),
        'pattern': this.i18n('Previews cache size must be a number.')
      }
    }

    this.SIGNUP_LIMIT = {
      VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
      MESSAGES: {
        'required': this.i18n('Signup limit is required.'),
        'min': this.i18n('Signup limit must be greater than 1.'),
        'pattern': this.i18n('Signup limit must be a number.')
      }
    }

    this.ADMIN_EMAIL = {
      VALIDATORS: [ Validators.required, Validators.email ],
      MESSAGES: {
        'required': this.i18n('Admin email is required.'),
        'email': this.i18n('Admin email must be valid.')
      }
    }

    this.TRANSCODING_THREADS = {
      VALIDATORS: [ Validators.required, Validators.min(1) ],
      MESSAGES: {
        'required': this.i18n('Transcoding threads is required.'),
        'min': this.i18n('Transcoding threads must be greater than 1.')
      }
    }
  }
开发者ID:jiang263,项目名称:PeerTube,代码行数:56,代码来源:custom-config-validators.service.ts

示例8: ngOnInit

 ngOnInit() {
   this.resetForm = this._fb.group(
     {
       password: ['', Validators.compose([Validators.required, Validators.pattern(passwordRegexp)])],
       confirm_password: ['', Validators.compose([Validators.required, Validators.pattern(passwordRegexp)])],
     }, 
     {
       validator: matchingPasswords('password', 'confirm_password')
     }
   );
   this._route.params.subscribe(params => {this._token = params['id']});
 }
开发者ID:bpblack,项目名称:baker-patrol-frontend,代码行数:12,代码来源:reset.component.ts

示例9: constructor

 constructor( vcr: ViewContainerRef, private _sharedData: SharedDataService, private _activatedRoute: ActivatedRoute, private _langService: LanguageService, private _authService: AuthService, private _router: Router, fb: FormBuilder) {
     this.loginForm = fb.group({
         'email' : [null, Validators.compose([Validators.required, Validators.pattern('[^ @]*@[^ @]*')])],
         'password' : [null, Validators.compose([Validators.required, Validators.pattern('^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$')])]
     });
     this._langService.loadLanguage().subscribe(response => {
         this.language = response.pcprepkit.login;
         this.header = response.pcprepkit.common.header;
         this.authMessages = response.pcprepkit.authMessages;
     });
     this.pcprepkitlogo = '../../assets/img/prepkitlogo.png';
 }
开发者ID:systers,项目名称:PC-Prep-Kit,代码行数:12,代码来源:login.component.ts

示例10: ngOnInit

  ngOnInit() {
    this.loadEmail = true;
    this.isLogin = true;
    this.loginForm = this.fb.group({
      'email': [null, Validators.compose([Validators.required, Validators.pattern('^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$')])],
      'password': [null, Validators.compose([Validators.required])]
    });

    this.loginRecover = this.fb.group({
      'emailRecover': [null, Validators.compose([Validators.required, Validators.pattern('^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$')])],
    });

  }
开发者ID:camilolozano,项目名称:finalAndroid2018-front,代码行数:13,代码来源:login.component.ts


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