Comparing version 2.4.3 to 2.5.0
@@ -6,2 +6,3 @@ { | ||
"invalid": "the value of {{key}} is not allowed to be {{value}}", | ||
"empty": "the value of {{key}} is not allowed to be empty", | ||
"with": { | ||
@@ -8,0 +9,0 @@ "parent": "cannot specify peer when key is not part of an object", |
@@ -397,3 +397,3 @@ // Load modules | ||
if (self._invalids.has(value, self._flags.insensitive)) { | ||
errors.push(internals.Any.error('any.invalid', { value: (value === '' ? 'empty' : self._invalids.key(value)) }, state)); | ||
errors.push(internals.Any.error(value === '' ? 'any.empty' : 'any.invalid', { value: (value === '' ? '' : self._invalids.key(value)) }, state)); | ||
if (options.abortEarly) { | ||
@@ -420,3 +420,3 @@ return errors; | ||
if (self._invalids.has(value, self._flags.insensitive)) { | ||
errors.push(internals.Any.error('any.invalid', { value: (value === '' ? 'empty' : self._invalids.key(value)) }, state)); | ||
errors.push(internals.Any.error(value === '' ? 'any.empty' : 'any.invalid', { value: (value === '' ? '' : self._invalids.key(value)) }, state)); | ||
if (options.abortEarly) { | ||
@@ -423,0 +423,0 @@ return errors; |
@@ -30,3 +30,3 @@ // Load modules | ||
values.push({ message: message, path: item.path || item.context.key }); | ||
values.push({ message: message, path: item.path || item.context.key, type: item.type }); | ||
} | ||
@@ -33,0 +33,0 @@ |
{ | ||
"name": "joi", | ||
"description": "Object schema validation", | ||
"version": "2.4.3", | ||
"version": "2.5.0", | ||
"repository": "git://github.com/spumko/joi", | ||
@@ -6,0 +6,0 @@ "main": "index", |
@@ -912,2 +912,26 @@ // Load modules | ||
it('returns error type in validation error', function (done) { | ||
var input = { | ||
notNumber: '', | ||
notString: true, | ||
notBoolean: 9 | ||
}; | ||
var schema = { | ||
notNumber: Joi.number().required(), | ||
notString: Joi.string().required(), | ||
notBoolean: Joi.boolean().required() | ||
} | ||
var err = Joi.validate(input, schema, { abortEarly: false }); | ||
expect(err).to.exist; | ||
expect(err._errors).to.have.length(3); | ||
expect(err._errors[0].type).to.equal('number.base'); | ||
expect(err._errors[1].type).to.equal('string.base'); | ||
expect(err._errors[2].type).to.equal('boolean.base'); | ||
done(); | ||
}); | ||
it('annotates error', function (done) { | ||
@@ -914,0 +938,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"without": "2", | ||
"invalid": "3", | ||
"empty": "3", | ||
"with": { | ||
@@ -8,0 +8,0 @@ "parent": "4", |
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
337077
4375