Comparing version 0.0.6 to 0.0.7
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -120,3 +120,2 @@ // Load modules | ||
Utils.assert(n instanceof RegExp, 'In Types.String.regex(n), the n must be a RegExp'); | ||
this.__valids.remove(undefined); | ||
@@ -123,0 +122,0 @@ return function (value, qs, key, req) { |
@@ -0,0 +0,0 @@ // Load modules |
{ | ||
"name": "joi", | ||
"description": "Object schema validation", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"author": "Van Nguyen <the.gol.effect@gmail.com>", | ||
"contributors":[ | ||
"contributors": [ | ||
"Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)", | ||
@@ -20,3 +20,3 @@ "Wyatt Preul <wpreul@gmail.com>" | ||
"dependencies": { | ||
"hoek": "0.0.x" | ||
"hoek": "0.4.x" | ||
}, | ||
@@ -23,0 +23,0 @@ "devDependencies": { |
@@ -1,3 +0,3 @@ | ||
<a href="/walmartlabs/blammo"><img src="https://raw.github.com/walmartlabs/blammo/master/images/from.png" align="right" /></a> | ||
# joi | ||
<a href="https://github.com/walmartlabs/blammo"><img src="https://raw.github.com/walmartlabs/blammo/master/images/from.png" align="right" /></a> | ||
![joi Logo](/images/joi.png) | ||
@@ -11,2 +11,3 @@ Object schema validation | ||
<img src="/images/validation.png" align="right" /> | ||
* [Introduction](#introduction "Introduction") | ||
@@ -26,2 +27,3 @@ * [Type Registry](#type-registry "Type Registry") | ||
* [Security Considerations](#security-considerations "Security Considerations") | ||
* [Examples](#examples "Examples") | ||
* [References](#references "References") | ||
@@ -78,3 +80,11 @@ * [Reference A: Other Types](#reference-a-other-types "Reference A: Other Types") | ||
Below is an example of how to validate an object against the above schema: | ||
```javascript | ||
Joi.validate(obj, schema, function (err) { | ||
// err will be set if the object failed to validate against the schema | ||
}); | ||
``` | ||
# Type Registry | ||
@@ -459,4 +469,56 @@ | ||
## Examples | ||
### Validating username and password | ||
```javascript | ||
var Joi = require('joi'); | ||
var schema = { | ||
username: Joi.types.String().alphanum().min(3).max(30).required(), | ||
password: Joi.types.String().regex(/[a-zA-Z0-9]{3,30}/).required(), | ||
}; | ||
var invalidObj = { username: 'roger' }; | ||
var validObj = { username: 'roger', password: 'pa55word' }; | ||
Joi.validate(invalidObj, schema, function (err) { | ||
if (err) throw err; | ||
}); | ||
Joi.validate(validObj, schema, function (err) { | ||
if (err) throw err; | ||
}); | ||
``` | ||
Executing the above code outputs the following: | ||
``` | ||
Error: [ValidationError]: the value of `password` is not allowed to be undefined | ||
``` | ||
### Validating a number | ||
```javascript | ||
var Joi = require('joi'); | ||
var schema = { | ||
num: Joi.types.Number().required() | ||
}; | ||
var obj = { num: '1' }; | ||
Joi.validate(obj, schema, function (err) { | ||
if (err) throw err; | ||
else console.log('Success!'); | ||
}); | ||
``` | ||
Executing the above code outputs the following: | ||
``` | ||
Success! | ||
``` | ||
## References | ||
@@ -471,2 +533,2 @@ ### Reference A: Other Types | ||
Unlike null, undefined is its own type with its own special properties. For the purposes of querystring validation, any blank or indefinite inputs will appear as blank strings (""). As far as I know, there is no way to force the undefined object into the querystring. Thus, unless otherwise proven, "undefined" will not be included in the Type Registry. | ||
Unlike null, undefined is its own type with its own special properties. For the purposes of querystring validation, any blank or indefinite inputs will appear as blank strings (""). As far as I know, there is no way to force the undefined object into the querystring. Thus, unless otherwise proven, "undefined" will not be included in the Type Registry. |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
267807
30
530
0
0
2622
+ Addedhoek@0.4.5(transitive)
- Removedasync@0.1.22(transitive)
- Removedhoek@0.0.21(transitive)
Updatedhoek@0.4.x