In some cases, we need to validate a users input against the results of an async request.
The example below shows us looking up the upcoming bank holidays from an API and then validating that the given date isn't a bank holiday.
get form() {
return lookupBankHolidays().then(bankHolidays => {
return form({
date: date.check('We are closed on Bank holidays', thisDate => !bankHolidays.includes(thisDate))
});
});
}
To support async lookups we need to modify how validations are handled to make them async aware.
In some cases, we need to validate a users input against the results of an async request.
The example below shows us looking up the upcoming bank holidays from an API and then validating that the given date isn't a bank holiday.
To support async lookups we need to modify how validations are handled to make them async aware.