Where should I declare the custom validators ?
Closed this issue · 4 comments
I'm using modules, where should I declare the custom validators ?
Define validators before you use them. Exporting objects in modules is an anti-pattern - the modules simply export the reference to that object. The updated object will persist.
@petesaia I'm also using modules with browserify/reactify. I have no idea how to where to declare the custom validators to have the "stick" to the exported validators object. It always seems to be redefined right before my form is rendered. I tried in to define a validator at the top of my module and also right inside the render method. Can you give an example define what you mean by "before you use them"?
Reopening. I will provide examples and perhaps a betters API to do this.
This has been greatly approved. Please see here: https://github.com/LevInteractive/react-serial-forms#custom-validators