• Overview
@angular/forms/signals

maxLength

function

Binds a validator to the given path that requires the length of the value to be less than or equal to the given maxLength. This function can only be called on string or array paths. In addition to binding a validator, this function adds MAX_LENGTH property to the field.

API

function maxLength<
  TValue extends ValueWithLengthOrSize,
  TPathKind extends PathKind = PathKind.Root,
>(
  path: FieldPath<TValue, TPathKind>,
  maxLength: number | LogicFn<TValue, number | undefined, TPathKind>,
  config?: BaseValidatorConfig<TValue, TPathKind> | undefined,
): void;

maxLength

void

Binds a validator to the given path that requires the length of the value to be less than or equal to the given maxLength. This function can only be called on string or array paths. In addition to binding a validator, this function adds MAX_LENGTH property to the field.

@parampathFieldPath<TValue, TPathKind>

Path of the field to validate

@parammaxLengthnumber | LogicFn<TValue, number | undefined, TPathKind>

The maximum length, or a LogicFn that returns the maximum length.

@paramconfigBaseValidatorConfig<TValue, TPathKind> | undefined

Optional, allows providing any of the following options:

@returnsvoid
Jump to details