menu
Channels
Team

React-Hook-Form watercooler

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

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
check out the validate function
  • reply
  • like
at the bottom of the talbe
  • reply
  • like
you can have multiple validation rules attached to your input
  • reply
  • like
Thank you Bill
like-fill
1
  • reply
  • like
my pleasure :)
  • reply
  • like

October 31, 2019 at 9:36pm
It seems like we can only have one type of validation in rule per field. For example, I can only use one pattern rule. What if I have two patterns to validate (this is important when I need to switch rules applied conditionally). Is there a way to provide an array of validation rules?
Edited
  • reply
  • like
Is passing an object in validate does not work for you?
<input
name="test"
ref={
register({
validate: {
smallCasePattern: value => /[a-z]+/.test(value),
digitPattern: value => /[0-9]{2}/.test(value)
}
})
}
/>
Edited
like-fill
1
  • reply
  • like
thanks i think you miss the valdiate
like-fill
1
  • reply
  • like

November 7, 2019 at 4:53am
Thanks . The document is not clear about, validate can be an object. I thought it could only be a function.
  • reply
  • like
How do I change the style/className of input when an error is displayed?
  • reply
  • like
Show more messages
private
This conversation has been locked