JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://raw.github.com/ericmbarnard/Knockout-Validation/master/Src/knockout.validation.js"></script>
<script src="https://raw.github.com/AndersMalmgren/Knockout.BindingConventions/master/src/Knockout.BindingConventions.js"></script>
<ul data-name="items">
<li><input data-name="name"></li>
</ul>
<button data-name="add">Add</button>
JavaScript
ViewModel = function() {
this.items = ko.observableArray();
this.items.subscribe(function() {
this.errors = ko.validation.group(this);
this.errors.showAllMessages();
}, this);
this.items([
new ItemViewModel("John"),
new ItemViewModel("Jane")
]);
};
ViewModel.prototype = {
add: function() {
this.items.push(new ItemViewModel());
}
};
ItemViewModel = function(name) {
this.name = ko.observable(name).extend({ required: true });
};
ko.validation.init({ grouping: { deep: true, observable: true } });
ko.applyBindings(new ViewModel());