menu

React Hook Form

๐Ÿ“‹ Custom React hooks for form validation without the hassle

Channels
Team

React-Hook-Form watercooler

July 31, 2019 at 1:06am
Show previous messages

August 12, 2019 at 11:12am
hey probably not right now. it's going to be a breaking change. For now i will leave errors out there, until the next major release i will fix this issue
  • reply
  • like
thanks for picking this up tho ๐Ÿ™๐Ÿป
  • reply
  • like
plus pick up those other issues as well.
  • reply
  • like
hey probably not right now. it's going to be a breaking change. For now i will leave errors out there, until the next major release i will fix this issue
I will wait for that :)
like-fill
1
  • reply
  • like

August 15, 2019 at 2:42pm
hm, how do we do validation of customInputs? I'm stuck with react-select over here, will probably remove it at some point but would be great to have validation on it meanwhile. I'm using https://github.com/react-hook-form/react-hook-form/blob/master/examples/customInput.tsx as reference. however adding a validate function to register() does not seem to do anything. triggerValidation does not do anything either..
Edited
  • reply
  • like

September 21, 2019 at 1:50am
Would like to try to submit a PR with an idea that I have. Do you have a contribution guide somewhere?
  • reply
  • like

October 11, 2019 at 11:10am
Hello. In redux-form we had a convenient behavior where form becomes 'touched' only after losing the focus but is validated on any change. That prevents unnecessary error messaging on first enter - like there is no weird message about wrong email at least until the user has entered it for the first time. On the other hand, I can disable submit button if the form is invalid, so making button enabled shows the user that he can press it.
  • reply
  • like
Can I imitate that behavior in react-hook-form? If I use 'onBlur' the user need to lose the focus on all fields to run the final validation enabling the button or showing all errors - that's not good from UX point of view.
  • reply
  • like
Oh, there is PR for that case :)
  • reply
  • like

October 19, 2019 at 8:22am
Quick question, If i had to get the watch value as object of object or array, how do i do that? What I mean, if i have few input checkboxes named as name="group1.new1" name="group1.new2" name="group2.new1" name="group2.new2" and I want the watch to give me back the object as group1: {new1: true, new2: false} etc. I think I saw a documentation or an example about it but I can't find it at the moment. So I am stuck :( Help me ASAP?
  • reply
  • like

October 19, 2019 at 9:48pm
can you try to use watch('group2')
  • reply
  • like

October 24, 2019 at 8:52pm
Quick question: What's the difference between getValues() and watch() ? Is there a reason to use one over the other?
Edited
  • reply
  • like
(apart from the fact that you can specify which field you want with watch)
Edited
  • reply
  • like
getValues() is cheap
  • reply
  • like
because it doesn't subscribe to the input
  • reply
  • like
watch() is when you want to watching some input all the time
  • reply
  • like
๐Ÿ‘€
  • reply
  • like
So for example you'd use getValues() in a callback and watch() to decide what to render?
  • reply
  • like
correct :)
  • reply
  • like
i should include that in the docs
  • reply
  • like
will do
like-fill
1
  • reply
  • like

October 28, 2019 at 2:15am
Hi all, when I have multiple validations, for example minLength on an optional field, how do I achieve this with the in-built validation function? I need minLength to validate only if the field isn't empty.
  • reply
  • like
Show more messages
private
This conversation has been locked