Skip to main content
Version: 0.7.0

maxSize

Validate that the array has at most max items. A non-array value fails.

Signature

NguardValidators.Array.maxSize(max: number): ValidatorFn
ParameterTypeDescription
maxnumberThe maximum number of items (inclusive)

Reactive forms

import { FormControl } from '@angular/forms';
import { NguardValidators } from 'ng-nguard';

new FormControl([], [NguardValidators.Array.maxSize(3)]);

Template-driven forms

<input ngModel name="tags" [nguardMaxSize]="3" />

Error key

{ maxSize: true }

Notes

  • A non-array value (including null/undefined) fails.

See also