Knockout-Contrib/Knockout-Validation — pull request #337 by stevegreatrex (2013-10-18 20:27:00+00:00)
Title: 266 mass apply rules

The is a suggested implementation of `setRules` that will let you set validations on an entire object graph from a single definition.

```javascript
var rules = {
//will apply required, min & max to viewModel.property
property: {
required: true,
min: 10,
max: 99,
},

//will apply required to viewModel.property2.childProperty
property2: {
childProperty: { required: true }
},

//will apply email to the elementProperty of each item in
//viewModel.arrayProperty
arrayProperty: {
elementProperty: { email: true }
}
};

var viewModel = {
property: ko.observable(),
property2: {
childProperty: ko.observable()
},
arrayProperty: ko.observableArray([
{ elementProperty: ko.observable() },
{ elementProperty: ko.observable() }
])
};

ko.validation.setRules(target, rules);
```

Eventually this could be used to pull validation definitions from models, from ASP.NET DataAnnotations, or from any other source.

Suggestions for improvements?