Comparing version 2.4.1 to 2.4.2
@@ -180,4 +180,6 @@ // Load modules | ||
for (var i = 0, il = peers.length; i < il; ++i) { | ||
if (!state.parent.hasOwnProperty(peers[i])) { | ||
return internals.Any.error('any.with.peer', { value: peers[i] }, state); | ||
var peer = peers[i]; | ||
if (!state.parent.hasOwnProperty(peer) || | ||
state.parent[peer] === undefined) { | ||
return internals.Any.error('any.with.peer', { value: peer }, state); | ||
} | ||
@@ -211,4 +213,7 @@ } | ||
for (var i = 0, il = peers.length; i < il; ++i) { | ||
if (state.parent.hasOwnProperty(peers[i])) { | ||
return internals.Any.error('any.without.peer', { value: peers[i] }, state); | ||
var peer = peers[i]; | ||
if (state.parent.hasOwnProperty(peer) && | ||
state.parent[peer] !== undefined) { | ||
return internals.Any.error('any.without.peer', { value: peer }, state); | ||
} | ||
@@ -237,3 +242,6 @@ } | ||
for (var i = 0, il = peers.length; i < il && present < 2; ++i) { | ||
if (state.parent.hasOwnProperty(peers[i])) { | ||
var peer = peers[i]; | ||
if (state.parent.hasOwnProperty(peer) && | ||
state.parent[peer] !== undefined) { | ||
++present; | ||
@@ -271,6 +279,3 @@ } | ||
if (value !== undefined && | ||
value !== null && | ||
value !== '') { | ||
if (value !== undefined) { | ||
return null; | ||
@@ -281,3 +286,4 @@ } | ||
var peer = peers[i]; | ||
if (state.parent.hasOwnProperty(peer)) { | ||
if (state.parent.hasOwnProperty(peer) && | ||
state.parent[peer] !== undefined) { | ||
return null; | ||
@@ -284,0 +290,0 @@ } |
{ | ||
"name": "joi", | ||
"description": "Object schema validation", | ||
"version": "2.4.1", | ||
"version": "2.4.2", | ||
"repository": "git://github.com/spumko/joi", | ||
@@ -6,0 +6,0 @@ "main": "index", |
@@ -25,5 +25,11 @@ // Load modules | ||
var result = Joi.validate(config[i][0], schema); | ||
if (result !== null && config[i][1]) { | ||
console.log(result); | ||
} | ||
if (result === null && !config[i][1]) { | ||
console.log(config[i][0]); | ||
} | ||
expect(result === null).to.equal(config[i][1]); | ||
@@ -30,0 +36,0 @@ } |
@@ -70,2 +70,21 @@ // Load modules | ||
it('validated without', function (done) { | ||
var schema = Joi.object({ | ||
txt: Joi.string().without('upc'), | ||
upc: Joi.string() | ||
}); | ||
Validate(schema, [ | ||
[{ upc: 'test' }, true], | ||
[{ txt: 'test' }, true], | ||
[{ txt: 'test', upc: null }, false], | ||
[{ txt: 'test', upc: '' }, false], | ||
[{ txt: 'test', upc: undefined }, true], | ||
[{ txt: 'test', upc: 'test' }, false] | ||
]); | ||
done(); | ||
}); | ||
it('validates xor', function (done) { | ||
@@ -166,3 +185,3 @@ | ||
Validate(schema, [ | ||
[{ upc: null }, false], | ||
[{ upc: null }, true], | ||
[{ upc: 'test' }, true], | ||
@@ -169,0 +188,0 @@ [{ txt: null }, false], |
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
335042
4324