Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 80x | import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';
import { Duration } from 'luxon';
export function intervalValidator(): ValidatorFn {
return (control: AbstractControl): ValidationErrors | null => {
const interval = Duration.fromISO(control.value);
return interval.isValid && interval.valueOf() ? null : { interval: { value: control.value } };
};
}
export function scrollToFirstInvalid() {
const control = document.querySelector('form .ng-invalid');
if (!control) return;
window.scroll({
top: control.getBoundingClientRect().top + window.scrollY,
left: 0,
behavior: 'smooth'
});
}
|