Comparing version 0.2.2 to 0.2.3
@@ -191,3 +191,7 @@ // Load modules | ||
for (var i in peers) { | ||
if (!obj.hasOwnProperty(peers[i]) || peers[i] === null) { | ||
if (!obj.hasOwnProperty(peers[i]) || | ||
typeof(obj[peers[i]]) === 'undefined' || | ||
obj[peers[i]] === null || | ||
obj[peers[i]] === '') { | ||
return false; | ||
@@ -212,7 +216,2 @@ } | ||
if (this.__modifiers.has('required')) { | ||
this.optional(); | ||
return this._xor(peers); | ||
} | ||
return function (value, obj, key, errors, keyPath) { | ||
@@ -227,2 +226,6 @@ | ||
if (this.__modifiers.has('required')) { | ||
return this.xor(Array.prototype.slice.call(arguments)); | ||
} | ||
this.add('without', this._without(Array.prototype.slice.call(arguments)), arguments); | ||
@@ -240,3 +243,3 @@ return this; | ||
var result = !!((typeof value !== 'undefined' && value !== null) ^ withFn(value, obj, key, errors, keyPath)); | ||
var result = !!((typeof value !== 'undefined' && value !== null && value !== '') ^ withFn(value, obj, key, errors, keyPath)); | ||
@@ -255,2 +258,6 @@ if (!result) { | ||
this.add('xor', this._xor(Array.prototype.slice.call(arguments)), arguments); | ||
this.__invalids.remove(undefined); | ||
this.__invalids.remove(null); | ||
this.__invalids.remove(''); | ||
return this; | ||
@@ -373,3 +380,3 @@ }; | ||
} | ||
if (this.__allowOnly === true && | ||
@@ -376,0 +383,0 @@ this.__valids._values.indexOf(value) < 0) { |
@@ -0,0 +0,0 @@ // Load modules |
@@ -39,3 +39,3 @@ // Load modules | ||
var result = typeof value === 'string'; | ||
var result = typeof value === 'string' || value === null || typeof value === 'undefined'; | ||
@@ -42,0 +42,0 @@ if (!result) { |
{ | ||
"name": "joi", | ||
"description": "Object schema validation", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"author": "Van Nguyen <the.gol.effect@gmail.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -85,2 +85,13 @@ // Load modules | ||
expect(Joi.validate({ txt: 'test', upc: 'test' }, config5)).to.not.be.null; | ||
expect(Joi.validate({ txt: 'test', upc: null }, config5)).to.be.null; | ||
expect(Joi.validate({ txt: 'test', upc: '' }, config5)).to.be.null; | ||
expect(Joi.validate({ txt: '', upc: 'test' }, config5)).to.be.null; | ||
expect(Joi.validate({ txt: null, upc: 'test' }, config5)).to.be.null; | ||
expect(Joi.validate({ txt: undefined, upc: 'test' }, config5)).to.be.null; | ||
expect(Joi.validate({ txt: 'test', upc: undefined }, config5)).to.be.null; | ||
expect(Joi.validate({ txt: 'test', upc: '' }, config5)).to.be.null; | ||
expect(Joi.validate({ txt: 'test', upc: null }, config5)).to.be.null; | ||
expect(Joi.validate({ txt: '', upc: undefined }, config5)).to.not.be.null; | ||
expect(Joi.validate({ txt: '', upc: '' }, config5)).to.not.be.null; | ||
done(); | ||
@@ -97,2 +108,13 @@ }); | ||
expect(Joi.validate({ txt: 'test', upc: 'test' }, config6)).to.not.be.null; | ||
expect(Joi.validate({ txt: 'test', upc: null }, config6)).to.be.null; | ||
expect(Joi.validate({ txt: 'test', upc: '' }, config6)).to.be.null; | ||
expect(Joi.validate({ txt: '', upc: 'test' }, config6)).to.be.null; | ||
expect(Joi.validate({ txt: null, upc: 'test' }, config6)).to.be.null; | ||
expect(Joi.validate({ txt: undefined, upc: 'test' }, config6)).to.be.null; | ||
expect(Joi.validate({ txt: 'test', upc: undefined }, config6)).to.be.null; | ||
expect(Joi.validate({ txt: 'test', upc: '' }, config6)).to.be.null; | ||
expect(Joi.validate({ txt: 'test', upc: null }, config6)).to.be.null; | ||
expect(Joi.validate({ txt: '', upc: undefined }, config6)).to.not.be.null; | ||
expect(Joi.validate({ txt: '', upc: '' }, config6)).to.not.be.null; | ||
done(); | ||
@@ -99,0 +121,0 @@ }); |
@@ -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
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
2992
278743