-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Another notation for FormDataInfo #5
Comments
The idea is great. However, there are some points that speak against it. I appreciate feedback on this.
|
I guess this a question of personal taste. I would like to have the unneeded information in FormDataInfo to see the shape of the output. But I guess other people would find that too much of a hassle.
Yeah, I wouldn't do this, too. Either the whole object or keep staying with the current FormDataInfo. Everything else is confusing.
Two options here:
More benefits:
|
Thank you for your feedback. How should |
I thought for a long time about it. I think there are three possible solutions:
I think there are valid cases for both 1. & 2. For example: -> 1.: The field is really optional and can be added or removed client side. You are okay if it is Third option is tricky: If you start to let the consumer decide on a per field basis (like But you could let the consumer decide on a global basis. Ultimately, I think the following api could be nice:
Maybe |
My fear is that the new notation will resemble a schema. Instead of inventing a new schema API, I would prefer to provide adapters for Valibot, Zod and other libraries. On the one hand, an own schema increases the complexity of this library, and on the other hand I have to maintain a second schema besides Valibot. Would you use your schema notation at all if there was an integration to Valibot? |
Yeah. I would totally use valibot / zod for that. I think that is the best solution. As you said the risk to create a second schema is way to high. |
Good to know. I will try to implement a first draft for Valibot in the next weeks. I'm still not sure how to structure this. I think that |
If you mean a version of the Internally, it could be implemented as a function that traverses Valibot schemas converting them into I don't see much value in it calling What do you think? |
Good idea! I'll take that into consideration. Do you have any idea what you would call the adapters? |
Maybe import { decode } from 'decode-formdata';
import { fromSchema } from 'decode-formdata/valibot';
const LoginSchema = /* ... */;
// for folks who aren't as concerned with the added perf. cost
decode(formData, fromSchema(LoginSchema)); // elsewhere inside a function
// alternatively
const decoder = fromSchema(LoginSchema);
decode(formData, decoder); // elsewhere inside a function This is the best I could think of, but I'm not great at naming things haha. What I do like about it is how composable it sounds to me. By the way, really appreciate the work you've been doing with Valibot and these other libs. Top-notch stuff indeed. |
Thank you for your kind words and feedback! I will probably look at the implementation in late December or January. |
What do you thing about a new notation for FormDataInfo? Something that looks more like the object that will get returned:
Benefits:
The text was updated successfully, but these errors were encountered: