Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Add date tests to validation rules #6

Open
ashleynolan opened this issue Dec 22, 2017 · 0 comments
Open

Add date tests to validation rules #6

ashleynolan opened this issue Dec 22, 2017 · 0 comments

Comments

@ashleynolan
Copy link

A rule for dates testing dates should be added to the validation checks.

Typical use case:

name: 'dateInFuture',
 test: () => {
     const dateToday = new Date();
     const currentMonth = dateToday.getMonth() + 1;
     const currentYear = dateToday.getFullYear();
     const selectedMonth = Number($.first('[id="ExpiryMonth"]').value);
     const selectedYear = Number($.first('[id="ExpiryYear"]').value);
     if (selectedYear > currentYear) {
         return true;
     }
     return selectedYear === currentYear && selectedMonth > currentMonth;
 }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant