(min: number)
| 468 | * See `Validators.min` for additional information. |
| 469 | */ |
| 470 | export 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. |
no outgoing calls
no test coverage detected
searching dependent graphs…