Socket
Socket
Sign inDemoInstall

joi

Package Overview
Dependencies
Maintainers
4
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

joi - npm Package Compare versions

Comparing version 4.3.1 to 4.4.0

12

lib/errors.js

@@ -30,11 +30,12 @@ // Load modules

var format = Hoek.reach(localized, this.type) || Hoek.reach(Language.errors, this.type);
var hasKey = false;
var message = format.replace(/\{\{\s*([^\s}]+?)\s*\}\}/ig, function (match, name) {
var hasKey = /\{\{\!?key\}\}/.test(format);
format = (hasKey ? format : '{{!key}} ' + format);
var message = format.replace(/\{\{(\!?)([^}]+)\}\}/g, function ($0, isSecure, name) {
hasKey = hasKey || name === 'key';
var value = Hoek.reach(self.context, name);
return Array.isArray(value) ? value.join(', ') : value.toString();
var normalized = Array.isArray(value) ? value.join(', ') : value.toString();
return (isSecure ? Hoek.escapeHtml(normalized) : normalized);
});
return hasKey ? message : this.context.key + ' ' + message;
return message;
};

@@ -74,2 +75,3 @@

var error = new Error(message);
error.name = 'ValidationError';
error.details = details;

@@ -76,0 +78,0 @@ error._object = object;

{
"name": "joi",
"description": "Object schema validation",
"version": "4.3.1",
"version": "4.4.0",
"repository": "git://github.com/spumko/joi",

@@ -6,0 +6,0 @@ "main": "index",

@@ -74,2 +74,3 @@ // Load modules

expect(err).to.exist;
expect(err.name).to.equal('ValidationError');
expect(err.message).to.equal('value 11. required 7. xor 7. email 19. date 18. alphanum 16. min 14. max 15. notEmpty 3. notEmpty 13');

@@ -89,2 +90,20 @@ done();

it('escapes unsafe keys', function (done) {
var schema = {
'a()': Joi.number()
};
Joi.validate({ 'a()': 'x' }, schema, function (err, value) {
expect(err.message).to.equal('a() must be a number');
Joi.validate({ 'b()': 'x' }, schema, function (err, value) {
expect(err.message).to.equal('b() is not allowed');
done();
});
});
});
it('returns error type in validation error', function (done) {

@@ -91,0 +110,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc