<commit_before>pass.js
=======

Javascript validation module. Runs from server or web, doesn't need a form.

**PLEASE NOTE. This project is still early stage. Tests are coming...**

## Usage

``` javascript
require('pass');

var rules,data,validator;

var first_name = "Billy";
var last_name = "Jones";
var email = "<EMAIL>";
var url = "http://theninthnode.com";
var password = "<PASSWORD>";

rules = [
	["first_name", "required", "first name"],
	["last_name", "required", "last name"],
	["email", "required,valid_email"],
	["url", "valid_url"],
	["password", "required,min_length:5"]
];

data = {
	first_name: first_name,	
	last_name: last_name,	
	email: email,	
	url: url,	
	password: password,	
};

validator = pass.validate(rules, data);

if(validator.failed()) {
	alert(validator.message());
	return false;
}
```

## Available Rules

* required
* matches
* valid_email
* min_length
* max_length
* exact_length
* greater_than
* less_than
* alpha
* alpha_numeric
* alpha_dash
* numeric
* integer
* decimal
* is_natural
* is_natural_no_zero
* valid_ip
* valid_base64
* valid_credit_card
* valid_url

## Methods

``` javascript
pass.failed() // BOOL
pass.message() // first error message as string
pass.allMessages() // array of error message strings
```<commit_msg>Updated methods description<commit_after>pass.js
=======

Javascript validation module. Runs from server or web, doesn't need a form.

**PLEASE NOTE. This project is still early stage. Tests are coming...**

## Usage

``` javascript
require('pass');

var rules,data,validator;

var first_name = "Billy";
var last_name = "Jones";
var email = "<EMAIL>";
var url = "http://theninthnode.com";
var password = "<PASSWORD>";

rules = [
	["first_name", "required", "first name"],
	["last_name", "required", "last name"],
	["email", "required,valid_email"],
	["url", "valid_url"],
	["password", "required,min_length:5"]
];

data = {
	first_name: first_name,	
	last_name: last_name,	
	email: email,	
	url: url,	
	password: password,	
};

validator = pass.validate(rules, data);

if(validator.failed()) {
	alert(validator.message());
	return false;
}
```

## Available Rules

* required
* matches
* valid_email
* min_length
* max_length
* exact_length
* greater_than
* less_than
* alpha
* alpha_numeric
* alpha_dash
* numeric
* integer
* decimal
* is_natural
* is_natural_no_zero
* valid_ip
* valid_base64
* valid_credit_card
* valid_url

## Methods

``` javascript
pass.validate(rules, data) // returns this object
pass.failed() // returns BOOL
pass.message() // returns first error message as string
pass.allMessages() // returns array of error message strings
```
{'fraction_non_alphanumeric': 0.15408085430968727, 'fraction_numerical': 0.002288329519450801, 'mean_word_length': 4.947845804988662, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '29981', 'n_tokens_mistral': 901, 'n_tokens_neox': 872, 'n_words': 240}