question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Smart Form Component and validate function

See original GitHub issue

First of all - I would like to congratulate you on a great library and docs!

I have implemented smart forms similar to these: https://codesandbox.io/s/react-hook-form-smart-form-component-eqb3n (Note this codesandbox link from your docs does not actually use smartform components or even work)

As we pass in a custom validate function to something like <Input/> we need access to the rest of the values on the form. For example, if I were to build a password changing screen - where the two passwords would have to match - with smart form components, the validate function would need access to things from the form. It would need the values from the form. It might want the touched values, etc.

What I wanted to propose was to add a 2nd parameter to the validate function. At a minimum the 2nd parameter would be getValues function - that a validator function could call if it needed them. At max, the 2nd parameter would be an object that contained '‘all’ of the functions from UseForm() call. That might be overkill, but we do need the getValues() function - and I could see people wanting ‘touched’. (no since in comparing and showing an error for passwords not matching until both fields are touched.

Thoughts on this idea or another suggestion?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:24 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
siam88commented, Apr 30, 2020

@bluebill1049 thanks a lot now it works for me ❤️

1reaction
bluebill1049commented, Dec 26, 2019

@tafelito you are doing correctly 😃 using getValues is right 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Usage - React Hook Form
React Hook Form has support for native form validation, which lets you validate inputs with your own rules. Since most of us have...
Read more >
How to validate a custom input using react-hook-form in Smart ...
How to validate select input field using React Hook Form? 1 · React Hook Form - Smart Components - form broken when Inputs...
Read more >
Smart form components - Tenon-ui
The set of Tenon-UI smart form components strive to make data management, validation and accessibility a very manageable task in React applications.
Read more >
Advanced Usage - Simple React forms validation
Performant, flexible and extensible forms with easy-to-use validation.
Read more >
How to create reusable form components with React Hook ...
It can also help consolidate styles and isolate input logic for easier unit testing. You can also use this component to enforce good ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found