Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date validator #92

Open
PowerKiKi opened this issue Dec 11, 2020 · 1 comment
Open

Date validator #92

PowerKiKi opened this issue Dec 11, 2020 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@PowerKiKi
Copy link
Member

PowerKiKi commented Dec 11, 2020

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)]);
}
@PowerKiKi PowerKiKi added enhancement New feature or request help wanted Extra attention is needed labels Dec 11, 2020
@PowerKiKi
Copy link
Member Author

Pseudo-code

function date(dateAadapter) : ValidatorFn {
    return (fromControl)=> { dateAdapter.isValid(formControl.value); }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant