common-errors
Advanced tools
Comparing version
@@ -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 @@ } |
59983
0.74%3
-25%56
1.82%771
0.65%1
Infinity%+ Added