defineFormkitEventHandler - this automatically validates data being passed on an endpoint, for use with action="/api/endpoint" for formkit forms in future. (It shouldn't be used on its own.)
it seems that node.input is somewhat async still, as I have to await node.ledger.settled('validating') to get a valid state - this seems like a regression from when we previously paired on this @justin-schroeder.
In the test, there seems to be some kind of shared context between the requests for valid/invalid data - the test is flakey. I wonder if this is an issue with formkit internals?
Next steps:
Automatic assignment/extraction of ID when action="" is applied to a form, so no need for allowlisting in the event handler.
Handle form submission state (pending/loading spinner, automatic submission of form id, data + route).
This is a work-in-progress PR to add automatic server-side form validation based on re-rendering a formkit form and populating it with data.
It adds the following server-side utils:
validateFormkitData
- this allows you to validate specific data, for a lower-level validation:defineFormkitEventHandler
- this automatically validates data being passed on an endpoint, for use withaction="/api/endpoint"
for formkit forms in future. (It shouldn't be used on its own.)Key points for review:
node.input
is somewhat async still, as I have to awaitnode.ledger.settled('validating')
to get a valid state - this seems like a regression from when we previously paired on this @justin-schroeder.Next steps:
action=""
is applied to a form, so no need for allowlisting in the event handler.Co-authored-by: Justin Schroeder justin@formkit.com