MaxLengthValidator

directive

npm Package @angular/forms
Module import { MaxLengthValidator } from '@angular/forms';
Source forms/src/directives/validators.ts

Overview

@Directive({
    selector: '[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]',
    providers: [MAX_LENGTH_VALIDATOR],
    host: { '[attr.maxlength]': 'maxlength ? maxlength : null' }
})
class MaxLengthValidator implements Validator, OnChanges {
  maxlength: string
  ngOnChanges(changes: SimpleChanges): void
  validate(c: AbstractControl): ValidationErrors | null
  registerOnValidatorChange(fn: () => void): void
}

Selectors

[maxlength][formControlName] [maxlength][formControl] [maxlength][ngModel]

Inputs

Description

A directive which installs the MaxLengthValidator for any formControlName,formControl, or control withngModelthat also has amaxlength` attribute.

Members

maxlength: string

ngOnChanges(changes: SimpleChanges): void

validate(c: AbstractControl): ValidationErrors | null

registerOnValidatorChange(fn: () => void): void

© 2010–2018 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v5.angular.io/api/forms/MaxLengthValidator