🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

common-errors

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

common-errors - npm Package Compare versions

Comparing version

to
0.4.15

tests/validation.js

3

index.js

@@ -30,2 +30,3 @@ var util = require('util');

exports.URIError = exports.helpers.generateClass('URIError', { extends: URIError });
exports.ValidationError = exports.Validation = require('./lib/validation');

@@ -42,4 +43,2 @@ exports.io = {

exports.Validation = require('./lib/validation');
exports.Generic = exports.helpers.generateClass('GenericError'); //deprecated

@@ -46,0 +45,0 @@

@@ -1,15 +0,4 @@

var util = require('util');
function ValidationError(message, code) {
this.name = "ValidationError";
this.message = message || '';
this.code = code;
this.toString = function(){
return this.message;
}
}
util.inherits(ValidationError, Error);
module.exports = ValidationError;
var generateClass = require('./helpers/class-generator');
module.exports = generateClass("ValidationError", {
args: ['message', 'code']
});

@@ -5,3 +5,3 @@ {

"description": "Common error classes and utility functions",
"version": "0.4.12",
"version": "0.4.15",
"repository": {

@@ -18,2 +18,3 @@ "type": "git",

"dependencies": {
"lodash": "= 2.4.1"
},

@@ -23,3 +24,2 @@ "devDependencies": {

"sinon": "*",
"lodash": "= 2.4.1",
"common-errors": "git://github.com/shutterstock/node-common-errors.git#global_extend.v1"

@@ -26,0 +26,0 @@ },

@@ -526,4 +526,4 @@ common-errors

var errors = [];
if(username.length < 3) errors.push(new errors.Validation("username must be at least two characters long", "VAL_MIN_USERNAME_LENGTH"));
if(/-%$*&!/.test(username)) errors.push(new errors.Validation("username may not contain special characters", "VAL_USERNAME_SPECIALCHARS"));
if(username.length < 3) errors.push(new errors.ValidationError("username must be at least two characters long", "VAL_MIN_USERNAME_LENGTH"));
if(/-%$*&!/.test(username)) errors.push(new errors.ValidationError("username may not contain special characters", "VAL_USERNAME_SPECIALCHARS"));
return errors;

@@ -530,0 +530,0 @@ }