NestedLink
NestedLink copied to clipboard
Add custom validation pattern to the docs
The pattern is to override component.linkAll().
- Call
linkAllof the base class to produce the relevant links. - Add custom validation checks.
- If needed, compute the
validationErrorand add it to the cache object. - return cache object.
It's damn cool pattern which deserves to be reflected in tutorials.
- I don't use the validation in valuelink, instead using validate.js. From a user standpoint I think the built in validation is less feature rich than validate.js and maybe overreaching in scope/scale of this library. Just comments in case you are wondering where to put development energy. Now this may be due to lack of docs explaining why I should use the built in validation instead of validate.js.
- Regarding the convenience function that returns a link to everything in the state: when using valuelink at work I have been enforcing a naming convention that all variables that are link objects end with 'Link' in the name. The convenience function that returns all the links doesn't do so. Thus I don't find it too useful.
- Imo more important to the docs is to go over how to modify multiple parts of the state at the same time in various situations. I found this is a common question from coworkers. I looked at the source code recently to figure this out and now know the correct answer.
Well, quite contrary, I believe that the links validation mechanics is the feature which makes this library truly worthy. :) This is the major reason this lib was developed and being used by ReactMVx, which powers Volicon/Verizon product lineup.
There's the article about the validation with links here.
https://medium.com/@gaperton/react-forms-with-value-links-part-2-validation-9d1ba78f8e49#.nllbm4cr7