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
As you probably know, FormData can contain both strings and files. Users may abuse the system by sending files instead of strings or by submitting numerous unknown fields.
Extracting all fields sent via form data poses a potential risk of consuming excessive computational resources. Using formData.get('field') is much more efficient in such cases than approaches like Object.fromEntries(formData.entries()), where we try to extract all the data from user input even if we are not going to use it.
Additionally, when you want to further optimize computational resources, you usually use the abortEarly flag for schema parser functions.
My suggestion is to write a function that will extract JSON data from FormData based on a provided schema, for example:
...or perhaps valibot should export parseFormData/safeParseFormData analogs to parse/safeParse, with the same function signatures and all the options they already support 🤔
Thoughts?
P.S.: Thank you for your enormous contributions to open source and especially valibot!
The text was updated successfully, but these errors were encountered:
Thanks for your feedback and for sharing this idea! Yes, such an improvement is planned, but at the moment Valibot is taking too much of my time. Once Valibot v1 is out (and I had a little break to recover 😅), I will probably work on it.
As you probably know,
FormData
can contain both strings and files. Users may abuse the system by sending files instead of strings or by submitting numerous unknown fields.Extracting all fields sent via form data poses a potential risk of consuming excessive computational resources. Using
formData.get('field')
is much more efficient in such cases than approaches likeObject.fromEntries(formData.entries())
, where we try to extract all the data from user input even if we are not going to use it.Additionally, when you want to further optimize computational resources, you usually use the
abortEarly
flag for schema parser functions.My suggestion is to write a function that will extract
JSON
data fromFormData
based on a provided schema, for example:Implementation suggestion via pseudocode:
...or perhaps
valibot
should exportparseFormData
/safeParseFormData
analogs toparse
/safeParse
, with the same function signatures and all the options they already support 🤔Thoughts?
P.S.: Thank you for your enormous contributions to open source and especially valibot!
The text was updated successfully, but these errors were encountered: