Socket
Socket
Sign inDemoInstall

joi

Package Overview
Dependencies
Maintainers
2
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

joi - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

images/joi.png

0

lib/index.js

@@ -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

1

lib/types/string.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc