MinLengthValidator

A directive which installs the MinLengthValidator for any formControlName, formControl, or control with ngModel that also has a minlength attribute.

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

选择器

[minlength][formControlName] [minlength][formControl] [minlength][ngModel]

输入参数

说明

该指令会把 MinLengthValidator 验证器安装到任何具有 minlength 属性的 formControlNameformControl 或带 ngModel 的控件上。

属性

属性名类型说明
minlength

方法

ngOnChanges(changes: SimpleChanges): void

参数

changes

Type: SimpleChanges.

返回值

void

validate(c: AbstractControl): ValidationErrors | null

参数

c

Type: AbstractControl.

返回值

ValidationErrors | null

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

参数

fn

Type: () => void.

返回值

void