Socket
Socket
Sign inDemoInstall

joi

Package Overview
Dependencies
Maintainers
4
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 4.5.0 to 4.6.0

9

lib/index.js
// Load modules
var Hoek = require('hoek');
var Any = require('./any');

@@ -115,2 +116,10 @@ var Cast = require('./cast');

root.assert = function (value, schema) {
var error = root.validate(value, schema).error;
if (error) {
throw new Error(error.annotate());
}
};
return root;

@@ -117,0 +126,0 @@ };

4

package.json
{
"name": "joi",
"description": "Object schema validation",
"version": "4.5.0",
"version": "4.6.0",
"repository": "git://github.com/spumko/joi",

@@ -17,3 +17,3 @@ "main": "index",

"topo": "1.x.x",
"isemail": "0.1.x"
"isemail": "1.x.x"
},

@@ -20,0 +20,0 @@ "devDependencies": {

@@ -6,3 +6,3 @@ <a href="https://github.com/spumko"><img src="https://raw.github.com/spumko/spumko/master/images/from.png" align="right" /></a>

Current version: **4.3.x**
Current version: **4.6.x**

@@ -20,2 +20,3 @@ [![Build Status](https://secure.travis-ci.org/spumko/joi.png)](http://travis-ci.org/spumko/joi)

- [`compile(schema)`](#compileschema)
- [`assert(value, schema)`](#assertvalue-schema)
- [`any`](#any)

@@ -36,3 +37,3 @@ - [`any.allow(value)`](#anyallowvalue)

- [`any.strict()`](#anystrict)
- [`any.default(value)`](#anydefault)
- [`any.default(value)`](#anydefaultvalue)
- [`any.concat(schema)`](#anyconcatschema)

@@ -225,2 +226,12 @@ - [`any.when(ref, options)`](#anywhenref-options)

### `assert(value, schema)`
Validates a value against a schema and throws if validation fails where:
- `value` - the value to validate.
- `schema` - the schema object.
```javascript
Joi.assert('x', Joi.number());
```
### `any`

@@ -227,0 +238,0 @@

@@ -1404,2 +1404,23 @@ // Load modules

});
describe('#assert', function () {
it('throws on invalid value', function (done) {
expect(function () {
Joi.assert('x', Joi.number());
}).to.throw('"x"\n\u001b[31m\n[1] value must be a number\u001b[0m');
done();
});
it('does not throw on valid value', function (done) {
expect(function () {
Joi.assert('4', Joi.number());
}).to.not.throw();
done();
});
});
});
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