Skip to content
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

File Inputs #4

Open
lukeed opened this issue Jan 19, 2019 · 0 comments
Open

File Inputs #4

lukeed opened this issue Jan 19, 2019 · 0 comments

Comments

@lukeed
Copy link
Owner

lukeed commented Jan 19, 2019

Currently file inputs are ignored – this was because handling File objects is usually very application-specific and validating them can be their own nightmare.

However, I've realized that the validation aspect is a moot point because you (the user) pass in your own validation rules, and formee will just respond to what your Functions & RegExps return values.

The only remaining "gotcha" is that the serialized return can no longer be passed directly into current fetch() requests if you have a File present. With the current formee version, tge data would just not include the file(s), making it safe for basic POST requests.

In order to upload files now, you have to manually check the DOM for values within your file inputs, and then upload them in a separate POST request or transform the current, single POST into a multipart request.

If formee were to serialize & validate file inputs, the only difference is that you'd have to check against the serialized data instead of adding to the serialized data. The cause for concern is that you may unknowingly attempt to send basic POST requests with multi-part bodies.

Either way, you have to formulate your outgoing HTTP request properly.


Edit: I should clarify that an object will still be returned, not a FormData instance.

Another (existing) shortcoming is that asynchronous validation methods won't be awaited. This is true for all validators currently, too, but may be highlighted with file validation.


What do you think? Should formee serialize & validate file inputs?


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant