Skip to content

Commit

Permalink
added examples of built-in validations to README
Browse files Browse the repository at this point in the history
  • Loading branch information
troygoode committed Jun 23, 2012
1 parent 48d86bd commit 03637a5
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.markdown
Expand Up @@ -21,6 +21,7 @@ It has been designed with usage in an Express-based JSON REST API in mind, and a
* Creating Guards : [Required Fields](#required-fields)
* Creating Guards : [Optional Fields](#optional-fields)
* Creating Guards : [Whitelisting](#whitelisting)
* Creating Guards : [Built-In Validations](#built-in-validations)
* Creating Guards : [Custom Validations](#custom-validations)
* Creating Guards : [Default Values](#default-values)
* Creating Guards : [Transformations](#transformations)
Expand Down Expand Up @@ -200,6 +201,41 @@ guard().frisk(input, function(err, result){
});
```

### Built-In Validations

TSA ships with a few validations built-in. Here are some examples:

```
var guard = tsa({
foo: tsa.require({ validate: tsa.validate.boolean() })
});
```
```
var guard = tsa({
foo: tsa.require({ validate: tsa.validate.true() })
});
```
```
var guard = tsa({
foo: tsa.require({ validate: tsa.validate.false() })
});
```
```
var guard = tsa({
foo: tsa.require({ validate: tsa.validate.numeric() })
});
```
```
var guard = tsa({
foo: tsa.require({ validate: tsa.validate.range(0, 10) })
});
```
```
var guard = tsa({
foo: tsa.require({ validate: tsa.validate.regex(/^bar$/g) })
});
```

### Custom Validations

```javascript
Expand Down

0 comments on commit 03637a5

Please sign in to comment.