@venncity/errors
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -6,2 +6,13 @@ # Change Log | ||
## [1.1.2](https://github.com/venn-city/npm-shelf/compare/@venncity/errors@1.1.1...@venncity/errors@1.1.2) (2019-04-15) | ||
### Bug Fixes | ||
* **errors:** use Joi.validate instead of Joi.assert in validator ([bf7adb8](https://github.com/venn-city/npm-shelf/commit/bf7adb8)) | ||
## [1.1.1](https://github.com/venn-city/npm-shelf/compare/@venncity/errors@1.1.0...@venncity/errors@1.1.1) (2019-04-14) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@venncity/errors", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"author": "Venn Engineering", | ||
@@ -30,3 +30,3 @@ "main": "src/index.js", | ||
}, | ||
"gitHead": "ed3a3d704da91d6c7ed014c9afe82cde78da3b5d" | ||
"gitHead": "aea4681ff492d2893dee491276d8202f72ba2446" | ||
} |
@@ -6,7 +6,16 @@ const { ClientDataValidationError, UnknownError } = require('./../errors/errors'); | ||
test('assert with default options', () => { | ||
expect(() => assert({ a: 'a' }, v.object().keys({ a: v.number() }))).toThrowError(/VennServerDataValidationError.*/); | ||
expect(() => assert({ a: 'a' }, { a: v.number() })).toThrowError(/VennServerDataValidationError.*/); | ||
}); | ||
test('check our custom joi defaults', () => { | ||
expect(() => assert({ a: 'a', b: 'b' }, { a: v.string() })).not.toThrow(); | ||
expect(() => assert({ a: 'a', b: 'b' }, { a: v.string(), c: v.number(), d: v.string() })).toThrow(); | ||
}); | ||
test('check our custom joi defaults override', () => { | ||
expect(() => assert({ a: 'a', b: 'b' }, { a: v.string() }, { joiOptions: { allowUnknown: false } })).toThrow(); | ||
}); | ||
test('assert with custom message and error', () => { | ||
expect(() => assert({ a: 'a' }, v.object().keys({ a: v.number() }), { message: 'msg', ValidationError: ClientDataValidationError })) | ||
expect(() => assert({ a: 'a' }, { a: v.number() }, { message: 'msg', ValidationError: ClientDataValidationError })) | ||
.toThrowError(ClientDataValidationError); | ||
@@ -16,3 +25,3 @@ }); | ||
test('assert with custom message, error and override clientVisible', () => { | ||
expect(() => assert({ a: 'a' }, v.object().keys({ a: v.number() }), | ||
expect(() => assert({ a: 'a' }, { a: v.number() }, | ||
{ | ||
@@ -19,0 +28,0 @@ message: 'msg', |
@@ -15,3 +15,7 @@ const Joi = require('joi'); | ||
try { | ||
Joi.assert(value, schema, { abortEarly, allowUnknown, presence }); | ||
Joi.validate(value, schema, { abortEarly, allowUnknown, presence }, (err) => { | ||
if (err) { | ||
throw err; | ||
} | ||
}); | ||
} catch (e) { | ||
@@ -18,0 +22,0 @@ if (e.isJoi) { |
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
9471
195