async-validate
Advanced tools
Comparing version 0.7.7 to 0.7.8
@@ -135,25 +135,1 @@ ### API | ||
Compare two arrays, return `false` if they are equal otherwise return an array that is the difference between the supplied arrays. | ||
##### required | ||
```javascript | ||
function required() | ||
``` | ||
Validate a required field, typically invoked from a rule function, raises an error if a required field is not present. | ||
##### pattern | ||
```javascript | ||
function pattern() | ||
``` | ||
Validate using a regexp pattern, typically invoked from a rule function, raises an error if a value fails to match a rule regexp pattern. | ||
##### range | ||
```javascript | ||
function range() | ||
``` | ||
Validates that a value falls within a given range or is of a specific length, typically invoked from a rule function, raises an error if a value is out of bounds. |
@@ -280,2 +280,34 @@ ## Guide | ||
#### Helper Plugins | ||
The following helper plugins ship with this package, you can use them all with: | ||
```javascript | ||
Schema.plugin([require('async-validate/plugin/util')]); | ||
``` | ||
##### required | ||
```javascript | ||
function required() | ||
``` | ||
Validate a required field, typically invoked from a rule function, raises an error if a required field is not present. | ||
##### pattern | ||
```javascript | ||
function pattern() | ||
``` | ||
Validate using a regexp pattern, typically invoked from a rule function, raises an error if a value fails to match a rule regexp pattern. | ||
##### range | ||
```javascript | ||
function range() | ||
``` | ||
Validates that a value falls within a given range or is of a specific length, typically invoked from a rule function, raises an error if a value is out of bounds. | ||
### Rule Properties | ||
@@ -386,2 +418,10 @@ | ||
This section describes using the processing options available when calling [validate](#validate). | ||
#### Bail | ||
To callback early on the first value that generates a validation error and only report a single error use the `bail` option. This is useful when a user interface only needs to show the first error condition or if continuing processing would add unnecessary overhead. | ||
Remember that a rule can generate multiple validation errors so if you need more fine grained control you can use the `single` and `first` options. | ||
#### Variables | ||
@@ -397,2 +437,2 @@ | ||
See the [vars test fixture](/test/spec/vars.js) for an example. | ||
See the [vars test fixture](/test/spec/vars.js) and [model fixture](/test/fixtures/model.js) for an example. |
{ | ||
"name": "async-validate", | ||
"description": "Asynchronous validation for node and the browser", | ||
"version": "0.7.7", | ||
"version": "0.7.8", | ||
"author": "muji <noop@xpm.io>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -22,2 +22,6 @@ Table of Contents | ||
* [Creating Plugins](#creating-plugins) | ||
* [Helper Plugins](#helper-plugins) | ||
* [required](#required) | ||
* [pattern](#pattern) | ||
* [range](#range) | ||
* [Rule Properties](#rule-properties) | ||
@@ -37,2 +41,3 @@ * [Type Identifier](#type-identifier) | ||
* [Validation](#validation) | ||
* [Bail](#bail) | ||
* [Variables](#variables) | ||
@@ -55,5 +60,2 @@ * [Messages](#messages) | ||
* [diff](#diff) | ||
* [required](#required) | ||
* [pattern](#pattern) | ||
* [range](#range) | ||
* [Developer](#developer) | ||
@@ -388,2 +390,34 @@ * [Test](#test) | ||
#### Helper Plugins | ||
The following helper plugins ship with this package, you can use them all with: | ||
```javascript | ||
Schema.plugin([require('async-validate/plugin/util')]); | ||
``` | ||
##### required | ||
```javascript | ||
function required() | ||
``` | ||
Validate a required field, typically invoked from a rule function, raises an error if a required field is not present. | ||
##### pattern | ||
```javascript | ||
function pattern() | ||
``` | ||
Validate using a regexp pattern, typically invoked from a rule function, raises an error if a value fails to match a rule regexp pattern. | ||
##### range | ||
```javascript | ||
function range() | ||
``` | ||
Validates that a value falls within a given range or is of a specific length, typically invoked from a rule function, raises an error if a value is out of bounds. | ||
### Rule Properties | ||
@@ -494,2 +528,10 @@ | ||
This section describes using the processing options available when calling [validate](#validate). | ||
#### Bail | ||
To callback early on the first value that generates a validation error and only report a single error use the `bail` option. This is useful when a user interface only needs to show the first error condition or if continuing processing would add unnecessary overhead. | ||
Remember that a rule can generate multiple validation errors so if you need more fine grained control you can use the `single` and `first` options. | ||
#### Variables | ||
@@ -505,3 +547,3 @@ | ||
See the [vars test fixture](https://github.com/freeformsystems/async-validate/blob/master/test/spec/vars.js) for an example. | ||
See the [vars test fixture](https://github.com/freeformsystems/async-validate/blob/master/test/spec/vars.js) and [model fixture](https://github.com/freeformsystems/async-validate/blob/master/test/fixtures/model.js) for an example. | ||
@@ -722,26 +764,2 @@ ### Messages | ||
##### required | ||
```javascript | ||
function required() | ||
``` | ||
Validate a required field, typically invoked from a rule function, raises an error if a required field is not present. | ||
##### pattern | ||
```javascript | ||
function pattern() | ||
``` | ||
Validate using a regexp pattern, typically invoked from a rule function, raises an error if a value fails to match a rule regexp pattern. | ||
##### range | ||
```javascript | ||
function range() | ||
``` | ||
Validates that a value falls within a given range or is of a specific length, typically invoked from a rule function, raises an error if a value is out of bounds. | ||
## Developer | ||
@@ -748,0 +766,0 @@ |
@@ -7,6 +7,4 @@ var data = { | ||
// mock model class (vars) | ||
function Model() { | ||
function Model() {} | ||
} | ||
function findUserById(id, cb) { | ||
@@ -13,0 +11,0 @@ // normally find in a database |
139151
826
2965