You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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...
memoizememoizeAsync
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 cacheditemExpiryInMs: 30_000// default 5_000}))
The text was updated successfully, but these errors were encountered:
Oh, yeah buffer… I thought it would be handy to be able to tell how many items are cached...
Example:
Someone types [email protected] which triggers an API call from the async validator
Then someone corrects this to [email protected] which is calling the API again
Finally, someone switches back to [email protected] which is not calling the API because the outcome of the validation is still cached and not outdated.
I hope clarifies the use-case a bit better.
I also like the idea of having debounce for certain values. 💪🏻
I posted this issue on X to get more feedback and ideas from other users. I am currently focusing on Valibot v1 and Standard Schema and think I will work on this issue after our stable v1 is out.
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:
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...
Example
The text was updated successfully, but these errors were encountered: