Form / Limits and guards from a metakit declaration
Take a form's limits and guards from its metakit declaration
Your input Schema already says an amount is above zero and at most 10,000.00,
and your withdrawal rule already says nobody takes out more than the balance.
Without help you write both again in the view: min, max and step on the
input, and a disabled check on the button that drifts from the real rule.
When those rules are written with metakit, a
library that keeps Schema rules and state transitions as data a program can
read, foldkit-form/metakit reads them for you. It turns the Schema's bounds
into input attributes, judges the transition against what has been typed so
far, and shows a rule over two keys (leave after you arrive) beside both keys
as soon as the dates break it.
A form's keys are its fields, and its input Schema is the Effect Schema of the value it decodes to. Install foldkit-form, @doeixd/metakit and effect. The blocks below continue one file; each result is in the comment under the code.