NestedLink icon indicating copy to clipboard operation
NestedLink copied to clipboard

Add custom validation pattern to the docs

Open gaperton opened this issue 8 years ago • 2 comments

The pattern is to override component.linkAll().

  • Call linkAll of the base class to produce the relevant links.
  • Add custom validation checks.
  • If needed, compute the validationError and add it to the cache object.
  • return cache object.

It's damn cool pattern which deserves to be reflected in tutorials.

gaperton avatar Jul 07 '17 18:07 gaperton

  1. 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.
  2. 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.
  3. 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.

richard-engineering avatar Jul 13 '17 21:07 richard-engineering

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

gaperton avatar Oct 20 '17 16:10 gaperton