W3cubDocs

/Angular 12

MaxValidator

directive

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

See also

Exported from

Selectors

Properties

Property Description
@Input()max: string | number

Tracks changes to the max bound to this directive.

inputName: 'max'
normalizeInput: (input: string): number => parseFloat(input)
createValidator: (max: number): ValidatorFn => maxValidator(max)

Description

Adding a max validator

The following example shows how to add a max validator to an input attached to an ngModel binding.

<input type="number" ngModel max="4">

© 2010–2021 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v12.angular.io/api/forms/MaxValidator