Comparing version 0.9.2 to 0.9.3
@@ -75,2 +75,5 @@ /** | ||
}, ''); | ||
// If for some reasons the first argument was empty | ||
if(argStr[0] === ',') argStr = argStr.slice(1); | ||
errMsg += 'Validation error: "'+data+'" '; | ||
@@ -77,0 +80,0 @@ errMsg += 'Rule "' + ruleName + '(' + argStr + ')" failed.'; |
@@ -10,3 +10,3 @@ /** | ||
/** | ||
/** | ||
* Type rules | ||
@@ -18,5 +18,23 @@ */ | ||
'empty' : function (x) { return x === ''; }, | ||
'required' : function (x) { return check(x).notEmpty(); }, | ||
'notEmpty' : function (x) { return check(x).notEmpty(); }, | ||
'required' : function (x) { | ||
// Transform data to work properly with node validator | ||
if(!x) x = ''; | ||
else if(typeof x.toString !== 'undefined') x = x.toString(); | ||
else x = '' + x; | ||
return check(x).notEmpty(); | ||
}, | ||
'notEmpty' : function (x) { | ||
// Transform data to work properly with node validator | ||
if(!x) x = ''; | ||
else if(typeof x.toString !== 'undefined') x = x.toString(); | ||
else x = '' + x; | ||
return check(x).notEmpty(); | ||
}, | ||
'undefined' : _.isUndefined, | ||
@@ -23,0 +41,0 @@ |
{ | ||
"name": "anchor", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"description": "Recursive validation library with support for objects and lists", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
36204
826
0