Knockout-Validation lib – clean patterns

Knockout-Validation on GitHub

which also leverages the jQueryValidation lib

All Bootstrap v3 compatible

Coolest architectural nugget = applying validation rules to VM observables (not inside HTML <input> markup)

one clear reason why that is a better way -> when the VM field is bound to multiple UI points, you only define the rule once vs many

see the wiki for all Native and User Contributed rules available OOB.
 
above field name in error message examples require the following global rule.message tweak…

overriding default error messages

** must execute BEFORE all observable.extend definitions on your VM **

HTML sample – basic knockout data-bind’ing (in case you’re new : )

HTML sample – summary error block

 

summary with errors listed

 

initialization

clear error boxes when blanking out properties (e.g. after a save)

gotta have a handy isValid right?

** must execute AFTER all observable.extend definitions on your VM **

Usage

CSS for comprehensiveness ( < word?)… completeness? arrrg what is the phrase that pays here (alternative languages welcome : )