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

Improve low level field management #33

Open
gaku-sei opened this issue Jan 18, 2021 · 0 comments
Open

Improve low level field management #33

gaku-sei opened this issue Jan 18, 2021 · 0 comments

Comments

@gaku-sei
Copy link
Contributor

So far the hook exposes some "low level" functions to handle field and their status:

let {addError} = Form.use()

React.useEffect(() => {
  addError("email", "An error")

  None
}, dependencies)

That's really convenient, especially for async validations and reactive updates, but it's also unsafe for 2 reasons:

  1. We use a string
  2. The errors are added/removed using the default == operator to compare the errors

I think these 2 issues can be addressed separately, I propose to add a cmp function to the Error module passed to the Formidable.Make functor. As for the first issue I don't have any idea, but we might have to develop a small layer on top of this logic to handle async validations.

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

No branches or pull requests

1 participant