Skip to main content
Version: 0.10.0

minSize

Validate that the array has at least min items. A non-array value fails.

Signature

NguardValidators.Array.minSize(min: number): ValidatorFn
ParameterTypeDescription
minnumberThe minimum number of items (inclusive)

Reactive forms

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

new FormControl([], [NguardValidators.Array.minSize(1)]);

Template-driven forms

<input ngModel name="tags" [nguardMinSize]="1" />

Error key

{ minSize: true }

Notes

  • A non-array value (including null/undefined) fails. Compose with an optional rule if empty should pass.

See also