-
-
Notifications
You must be signed in to change notification settings - Fork 256
Open
Labels
Milestone
Description
Preface - valibot is awesome
Thank you all for developing this library.
It is the most type-safe library, I have ever used.
It comes with great DX & the docs become better and better.
Use Case
Forms:
- Sometimes we need to validate certain fields asynchronously.
- It would be nice if the schema could cache certain inputs and the results of the asynchronous validations to not trigger asynchronous operations if not needed.
New action memoize
Wouldn't it be nice if we could memoize
the executions inside a schema, where it is needed?
We could provide a synchronous and an asynchronous version...
memoize
memoizeAsync
Example
v.pipeAsync(
v.string(),
v.memoizeAsync(
v.customAsync(input => fetch(`/api/email/${input}`).then(() => /* ... */)), {
buffer: 10, // default 1 - tells how many inputs with their respective result are cached
itemExpiryInMs: 30_000 // default 5_000
})
)
fabian-hiller, JustGreg, EltonLobo07 and HymanZHAN