1.1.5 • Published 7 years ago

skelleton-data-validation v1.1.5

Weekly downloads
5
License
ISC
Repository
github
Last release
7 years ago

skelleton-data-validation

Node.js / Javascript form and data Validationfor backend services. Works independently or with services like Express.

For front end form validation check out:

https://github.com/joeycaughey/jquery.forms

Initialize the validator.

validate.init();

Check against data.

validate.check(
	"contest_slug", 
	req.body.contest_slug, 
	"No contest has been selected.", 
	["notEmpty"]
);

validate.check(
	"name", 
	req.body.name, 
	"You must enter your name.", 
	["notEmpty"]
);

validate.check(
	"email", 
	req.body.email, 
	"You must enter a valid email.", 
	["notEmpty", "isEmail"]
);

validate.check(
	"zip_postal_code", 
	req.body.zip_postal_code, 
	"You must enter a valid postal code.", 
	["notEmpty", "isPostalCode"]
);

if (!validate.valid()) {
    // Data Does not validate
    console.log({ success: false,  errors: validate.errors() })
} else {
	// Data validates
	console.log({ success: true})
}

Add your own validations. It excepts a sigle validator or an array of them.

validate.add_validators(
	{
		notEmpty: function(value) {
			return (value != "") ? true : false;
		}
	}
);
1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago