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