lukeed / lukeed/formee

File Inputs

Open
#4 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feedback wanted
Dominant language
JavaScript
Stars
440
Forks
11
PR merge metrics
No merged PRs in 30d

Description

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?

[![](https://api.gh-polls.com/poll/01D1KXWYX3FWMZCC0928M3G069/Yes%2C%20please.)](https://api.gh-polls.com/poll/01D1KXWYX3FWMZCC0928M3G069/Yes%2C%20please./vote)
[![](https://api.gh-polls.com/poll/01D1KXWYX3FWMZCC0928M3G069/No%2C%20thank%20you.)](https://api.gh-polls.com/poll/01D1KXWYX3FWMZCC0928M3G069/No%2C%20thank%20you./vote)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the form serialization and validation entry points for DOM file inputs, then review how the serialized object is intended to be used with fetch requests. Define whether File objects are included, how user-supplied functions and regular expressions validate them, and how asynchronous validators are handled. Done means the behavior and multipart-request implications are documented and covered by file-input validation tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.