DEV Community

Discussion on: Form Validation In ReactJS by building A Reusable Custom hook⚓

Collapse
 
ourystd profile image
Oury Diallo

Thanks for this article.

I think that this hook can be improved if we can find a way to pass validation function as parameter. What do you think about that ?

Collapse
 
codebucks profile image
CodeBucks

Yeah we can pass validation function just like formLogin. If you have lot's of forms in your website then passing validation function makes more sense.

Collapse
 
krishnasaini profile image
krishna-saini

why you want to pass validation function as parameter

Collapse
 
codebucks profile image
CodeBucks

When you have multiple forms in your application, then you will need different validations as per the different fields of the forms and it becomes hard to manage if we keep adding validations for all the fields in just one function. That's why it is best to create separate validation functions for separate form then pass it.