Hi
How to use below code to compare 2 dates using custom directive. Where i should write the below code so it can be used in any component where Data validation of this type is required.
import {FormGroup, ValidatorFn, Validators} from '@angular/forms'; export function creatDateRangeValidator(): ValidatorFn { return (form: FormGroup): ValidationErrors | null => { const start:Date = form.get("startAt").value; const end:Date = form.get("endAt").value; if (start && end) { const isRangeValid = (end.getTime() - start.getTime() > 0); return isRangeValid ? null : {dateRange:true}; } return null; } }
Thanks