Date validator
PowerKiKi opened this issue · comments
A date validator to which we give a DateAdapter
and that validate that whatever we give is either a valid string representation of a date, or a Date
. So basically forwarding to DateAdapter.isValid
.
It should be used used pretty much for every datepicker in all our projects.
Usage is something like:
constructor(
dateAdapter: DateAdapter,
) {
const formControl = new FormControl(null, [date(dateAdapter)]);
}
Pseudo-code
function date(dateAadapter) : ValidatorFn {
return (fromControl)=> { dateAdapter.isValid(formControl.value); }
}