Skip to content

Handle async forms #88

@michaeldfallen

Description

@michaeldfallen

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions