MCPcopy Index your code
hub / github.com/angular/angular / maxValidator

Function maxValidator

packages/forms/src/validators.ts:486–496  ·  view source on GitHub ↗
(max: number)

Source from the content-addressed store, hash-verified

484 * See `Validators.max` for additional information.
485 */
486export function maxValidator(max: number): ValidatorFn {
487 return (control: AbstractControl): ValidationErrors | null => {
488 if (control.value == null || max == null) {
489 return null; // don't validate empty values to allow optional controls
490 }
491 const value = parseFloat(control.value);
492 // Controls with NaN values after parsing should be treated as not having a
493 // maximum, per the HTML forms spec: https://www.w3.org/TR/html5/forms.html#attr-input-max
494 return !isNaN(value) && value > max ? {'max': {'max': max, 'actual': control.value}} : null;
495 };
496}
497
498/**
499 * Validator that requires the control have a non-empty value.

Callers 2

MaxValidatorClass · 0.90
maxMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…