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


TypeScript Validators.max方法代码示例

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


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

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

示例2: createValidators

 /**
  * Creates form validationdepending [ITdDynamicElementConfig] properties.
  */
 createValidators(config: ITdDynamicElementConfig): ValidatorFn {
   let validator: ValidatorFn;
   if (config.required) {
     validator = Validators.required;
   }
   if (config.max || config.max === 0) {
     validator = Validators.compose([validator, Validators.max(parseFloat(config.max))]);
   }
   if (config.min || config.min === 0) {
     validator = Validators.compose([validator, Validators.min(parseFloat(config.min))]);
   }
   if (config.maxLength || config.maxLength === 0) {
     validator = Validators.compose([validator, Validators.maxLength(parseFloat(config.maxLength))]);
   }
   if (config.minLength || config.minLength === 0) {
     validator = Validators.compose([validator, Validators.minLength(parseFloat(config.minLength))]);
   }
   // Add provided custom validators to the validator function
   if (config.validators) {
     config.validators.forEach((validatorConfig: ITdDynamicElementValidator) => {
       validator = Validators.compose([validator, validatorConfig.validator]);
     });
   }
   return validator;
 }
开发者ID:Teradata,项目名称:covalent,代码行数:28,代码来源:dynamic-forms.service.ts

示例3: validate

  validate(c: AbstractControl): { [key: string]: any; } {

    if (this.element.nativeElement.max) {
      const max = parseInt(this.element.nativeElement.max, 10 );
      return  Validators.max(max)(c);
    }
    return null;
  }
开发者ID:CHBaker,项目名称:angular-cesium,代码行数:8,代码来源:max-validtor.directive.ts

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

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

示例6: ngOnInit

 ngOnInit() {
   this.createForm = this.fb.group({
     make: ["", [Validators.minLength(4), Validators.required]],
     model: ["", [Validators.minLength(4), Validators.required]],
     year: ["", [Validators.min(1950), Validators.max(2050)]],
     description: ["", [Validators.minLength(11)]],
     price: ["", [Validators.min(1)]],
     imageUrl: ["", [Validators.required]],
     material: [""]
   });
 }
开发者ID:stwel,项目名称:SoftUni,代码行数:11,代码来源:create-furniture.component.ts

示例7: constructor

 constructor(
     private tokenService: AngularTokenService,
     private gameService: GameService,
     private router: Router,
     private formBuilder: FormBuilder,
 ) {
   this.createForm = this.formBuilder.group({
     name: ['', [Validators.required, Validators.minLength(4), Validators.maxLength(128)]],
     numberOfPlayers: [4, [Validators.required, Validators.min(1), Validators.max(8)]]
   });
 }
开发者ID:ffeldhaus,项目名称:soil,代码行数:11,代码来源:admin.component.ts

示例8: it

    it('should always validate the permanentValidators', () => {
      CdValidators.validateIf(
        form.get('x'),
        () => ((form && form.getValue('y')) || 0) > 10,
        [Validators.min(7), Validators.max(12)],
        [Validators.required],
        [form.get('y')]
      );

      formHelper.expectValid('x');
      formHelper.setValue('x', '');
      formHelper.expectError('x', 'required');
    });
开发者ID:IlsooByun,项目名称:ceph,代码行数:13,代码来源:cd-validators.spec.ts

示例9: getValidators

 protected getValidators() {
     const validators = new Array<ValidatorFn>();
     if (this._definition.validationDefinition.isRequired) {
         validators.push(Validators.required);
     }
     const min = this._definition.validationDefinition.min;
     if (min || min === 0) {
         validators.push(Validators.min(min as number));
     }
     const max = this._definition.validationDefinition.max;
     if (max || max === 0) {
         validators.push(Validators.max(max as number));
     }
     return validators;
 }
开发者ID:PjMitchell,项目名称:ConfigServer,代码行数:15,代码来源:interger-input.component.ts


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