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

Function minValidator

packages/forms/src/validators.ts:470–480  ·  view source on GitHub ↗
(min: number)

Source from the content-addressed store, hash-verified

468 * See `Validators.min` for additional information.
469 */
470export function minValidator(min: number): ValidatorFn {
471 return (control: AbstractControl): ValidationErrors | null => {
472 if (control.value == null || min == null) {
473 return null; // don't validate empty values to allow optional controls
474 }
475 const value = parseFloat(control.value);
476 // Controls with NaN values after parsing should be treated as not having a
477 // minimum, per the HTML forms spec: https://www.w3.org/TR/html5/forms.html#attr-input-min
478 return !isNaN(value) && value < min ? {'min': {'min': min, 'actual': control.value}} : null;
479 };
480}
481
482/**
483 * Validator that requires the control's value to be less than or equal to the provided number.

Callers 2

MinValidatorClass · 0.90
minMethod · 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…