Project Description

knockout-validator is an extensible model validation system for knockout framework, that besides normal validations it handles well nested validations and array validations. Validation is performed on the view model. The UI can selectively register to display validation results.


Working with knockout ( system is extremely useful for any ajax enabled rich application. We create complex view models which are projected through knockout system to the user interface.
One thing the developer will soon or later will have to handle is validation. For this there are various approaches such as:

  1. Manually, by using observable extensions according to knockout documentation (
  2. Manually, by using computed observables according to knockout documentation (
  3. Using a third party validation system, like jquery validation plugin (
  4. And last but not least, using the excellent knockout-validation ( by Eric Barnard which, according to my opinion, would be the best approach.

The need for knockout-validator was raised because I needed a validation system that

  1. could handle well array validations and array items validations
  2. could watch and resubscribe to observables even if they are nested
  3. could provide hierarchical validation, in that in a complex view model, with many levels of nesting for example Person=> Contacts[]=> Contact=> Addresses[]=>Address=>PostalCode I could subscribe for changes only to the Addresses[] item, or to the full Person view model etc with the minimum of coding (no need to create computed observables to forward validation results to parent objects etc)
  4. would give me with zero-coding the opportunity to track changes to my objects ( so that i could get events/subscribe not only to "isValid" observable but also to hasValidChanges observable, which will be raised only if i have valid changes)
  5. separate well UI vs Model and perform clean View Mode validation which will be projected -and not merged- with the UI
  6. create validations of ko.computed (or ko.dependentObservable) objects
  7. display validation result to whichever ui element ( eg. you can have an input element, bind its value to some object but map its validation result from the validation of a computed element and not the input's value)
  8. create custom function validations

Documentation and samples will be added soon.

For starters you can download the initial release from "Downloads" section.


You can follow me on twitter:

View George Mavritsakis's profile on LinkedIn

Last edited Oct 12, 2012 at 10:37 AM by gmavritsakis, version 10