Knockout-Contrib / Knockout-Validation

A validation library for Knockout JS
1.02k stars 379 forks source link

Controlled "deep" validation + observed find children #120

Open lcorneliussen opened 12 years ago

lcorneliussen commented 12 years ago

I have a couple of problems with the current validation engine:

I have a draft locally which fixes the first to problems by explicitly telling ko.validation which path to follow when validating. Currently this is done by extending with { followOnValidation: true }.

It will then also subscribe to those extended objects and update the "validatables" for the group correspondingly.

What do you think of that approach?

ericmbarnard commented 12 years ago

@lcorneliussen

I'm interested - but not sure I'm grasping what you're trying to describe without seeing it.

I've had on my list of "TODOs" for while to take a deeper look at the traverse logic on the group function. It would be relatively easy to add some more intelligence to that in the form of:

  1. keeping a hasVisited array and checking each node against that before walking it
  2. surrounding some of the walking with more try/catch handlers in case things go awry
  3. Pulling the traverse function out into a named function separate from the group function so that we can write tests on it

Those were my ideas - any interest on blending the 2?

lcorneliussen commented 12 years ago

https://github.com/faktumsoftware/Knockout-Validation/commit/614f15a86d7b0913ae45c0f03810e262bdce7882

I don't like my approach, but it works for me now.... Would you have a look at it?

Approach is to keep a list of children pr. "node" in the validation tree... Then combine those lists using ko.computed - on the root...

Hernandesjunio commented 8 years ago

I have a simple solution for deep validation knockout, may be can help you. https://github.com/Hernandesjunio/KnockoutModelChainValidation