sidgujrathi / checkjs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Checkjs

Checkjs is a simple Javascript library for validating your data. Currently it supports URL, Number, US Phone Number, Credit Card Number, Email and US Zip Code.

Installation

Browser

<script src="checkjs.min.js"></script>

Basic Usage

Checkjs.validate(data, callback);

data {Object} - The data and rule you want to validate

callback A callback function with result and error messege if any

Example Usage - Validating email

var data_object = {
	data: 'johndoe@gmail.com',
	rule: "Email"
};

Checkjs.validate(data_object, function(result, messege){
	
	console.log(result +" "+messege)
});

Available Rules

Currently Checkjs accepts and validates against only 6 rules. []

Url

This rule validates data for valid Url formate as http://google.com.

Number

This rule checks weather data is number or not.

Email

This rule validates data for valid email address.

Phone

This rule check weather given data is in correct US phone number format or not.

####ZipCode

This rule check weather given data is in correct US zip code format or not.

CreditCard

This rule check for valid credit card number format.

##Refernces For library skeleton.

Postfeed.js

For regular expression refernce

ValidatorJS

License

Checkjs is distributed under the MIT license.

About

License:MIT License


Languages

Language:JavaScript 100.0%