Comparing version 2.4.2 to 2.4.3
@@ -36,4 +36,5 @@ // Load modules | ||
var lowercase = value.toLowerCase(); | ||
return (lowercase === 'true' || lowercase === 'yes' ? true : (lowercase === 'false' || lowercase === 'no' ? false : value)); | ||
value = value.toLowerCase(); | ||
return (value === 'true' || value === 'yes' || value === 'on' ? true | ||
: (value === 'false' || value === 'no' || value === 'off' ? false : value)); | ||
}; |
@@ -200,3 +200,3 @@ // Load modules | ||
if (options.stripUnknown) { | ||
return null; | ||
return errors.length ? errors : null; | ||
} | ||
@@ -203,0 +203,0 @@ |
{ | ||
"name": "joi", | ||
"description": "Object schema validation", | ||
"version": "2.4.2", | ||
"version": "2.4.3", | ||
"repository": "git://github.com/spumko/joi", | ||
@@ -6,0 +6,0 @@ "main": "index", |
@@ -26,2 +26,13 @@ // Load modules | ||
it('validates both valid() and with()', function (done) { | ||
var b = Joi.object({ | ||
first: Joi.any().valid('value').with('second'), | ||
second: Joi.any() | ||
}); | ||
Validate(b, [[{ first: 'value' }, false]]); | ||
done(); | ||
}); | ||
describe('#strict', function () { | ||
@@ -28,0 +39,0 @@ |
@@ -45,9 +45,16 @@ // Load modules | ||
it('should handle work with nullOk', function (done) { | ||
it('converts string values and validates', function (done) { | ||
var rule = Joi.boolean().nullOk(); | ||
var rule = Joi.boolean(); | ||
Validate(rule, [ | ||
['1234', false], | ||
[false, true], | ||
[null, true] | ||
[true, true], | ||
[null, false], | ||
['on', true], | ||
['off', true], | ||
['true', true], | ||
['false', true], | ||
['yes', true], | ||
['no', true] | ||
]); done(); | ||
@@ -54,0 +61,0 @@ }); |
@@ -699,2 +699,21 @@ // Load modules | ||
it('fails to validate with incorrect property when asked to strip unkown keys without aborting early', function (done) { | ||
var schema = { | ||
a: Joi.number().min(0).max(3), | ||
b: Joi.string().valid('a', 'b', 'c'), | ||
c: Joi.string().email().optional() | ||
}; | ||
var obj = { | ||
a: 1, | ||
b: 'f', | ||
d: 'c' | ||
}; | ||
var err = Joi.validate(obj, schema, { stripUnknown: true, abortEarly: false }); | ||
expect(err).to.exist; | ||
done(); | ||
}); | ||
it('should pass validation with extra keys when allowUnknown is set', function (done) { | ||
@@ -701,0 +720,0 @@ |
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
336226
4355