Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

brabantcourt/lopeway.knockout-validation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#lopeway.knockout-validation

Additional rules for the KnockoutJS Validation library

The additional rules are:

  • lopeway.validation.rules.validObject
  • lopeway.validation.rules.validArray

###How to use

####validObject####

ko.validation.rules.validObject = lopeway.validation.rules.validObject;
ko.validation.registerExtenders();

viewModel = {
	person: ko.observable({
		name: ko.observable().extend({ required: true }),
		age: ko.observable().extend({ min: 0, max: 120 })
	}.extend({ validObject: true })
};
ko.applyBindings(viewModel);

####validArray####

ko.validation.rules.validArray = lopeway.validation.rules.validArray;
ko.validation.registerExtenders();

viewModel = {
	person: ko.observableArray([{
		name: ko.observable().extend({ required: true }),
		age: ko.observable().extend({ min: 0, max: 120 })
	}, {
		name: ko.observable().extend({ required: true }),
		age: ko.observable().extend({ min:0, max:120 })
	}].extend({ validArray: true })
};
ko.applyBindings(viewModel);

###Examples

A standalone example that uses both rules is at index.html

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published