Comparing version 0.0.10 to 0.0.11
66
index.js
@@ -5,3 +5,3 @@ //----------------------------------------------------- | ||
// Site: 666.io | ||
// Version: 0.00.010 | ||
// Version: 0.00.011 | ||
// | ||
@@ -51,3 +51,3 @@ //----------------------------------------------------- | ||
if( | ||
return !( | ||
(typeof(options.enum) !== "undefined" && options.enum.indexOf(input) === -1) || | ||
@@ -57,7 +57,4 @@ (typeof(options.pattern) !== "undefined" && !options.pattern.test(input)) || | ||
(typeof(options.max) !== "undefined" && input.length > options.max) | ||
) | ||
return false; | ||
); | ||
return true; | ||
case "integer": | ||
@@ -67,3 +64,3 @@ if(typeof(input) !== "number" || isNaN(input)) | ||
if( | ||
return !( | ||
(input !== parseInt(input, 10)) || | ||
@@ -73,7 +70,4 @@ (typeof(options.enum) !== "undefined" && options.enum.indexOf(input) === -1) || | ||
(typeof(options.max) !== "undefined" && input > options.max) | ||
) | ||
return false; | ||
); | ||
return true; | ||
case "float": | ||
@@ -83,16 +77,16 @@ if(typeof(input) !== "number" || isNaN(input)) | ||
if( | ||
return !( | ||
(typeof(options.enum) !== "undefined" && options.enum.indexOf(input) === -1) || | ||
(typeof(options.min) !== "undefined" && input < options.min) || | ||
(typeof(options.max) !== "undefined" && input > options.max) | ||
) | ||
return false; | ||
); | ||
return true; | ||
case "date": | ||
if(!input || !(input instanceof(Date)) || !input.getTime()) | ||
if(!(input instanceof(Date)) || !input.getTime()) | ||
return false; | ||
return true; | ||
return !( | ||
(typeof(options.min) !== "undefined" && input < options.min) || | ||
(typeof(options.max) !== "undefined" && input > options.max) | ||
); | ||
@@ -103,7 +97,4 @@ case "hashTable": | ||
if(typeof(input) === "object") | ||
return true; | ||
return typeof(input) === "object"; | ||
return false; | ||
case "array": | ||
@@ -113,16 +104,10 @@ if(!Array.isArray(input)) | ||
if( | ||
return !( | ||
(typeof(options.min) !== "undefined" && input.length < options.min) || | ||
(typeof(options.max) !== "undefined" && input.length > options.max) | ||
) | ||
return false; | ||
); | ||
return true; | ||
case "json": | ||
if(typeof(input) !== "object") | ||
return false; | ||
return typeof(input) === "object"; | ||
return true; | ||
//-----------------------]> | ||
@@ -142,6 +127,6 @@ | ||
case "lowercase": | ||
return typeof(input) === "string" && input === input.toLowerCase() | ||
return typeof(input) === "string" && input === input.toLowerCase(); | ||
case "uppercase": | ||
return typeof(input) === "string" && input === input.toUpperCase() | ||
return typeof(input) === "string" && input === input.toUpperCase(); | ||
@@ -166,3 +151,3 @@ //-----------------------]> | ||
case "email": | ||
return typeof(input) == "string" && !!input.match(/^(?:[\w\!\#\$\%\&\"\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\"\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/); | ||
return typeof(input) === "string" && !!input.match(/^(?:[\w\!\#\$\%\&\"\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\"\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/); | ||
@@ -257,2 +242,5 @@ case "url": | ||
if(version && version != 4 && version != 6) | ||
return false; | ||
if(!version && !ipV4() && !(/^::|^::1|^([a-fA-F0-9]{1,4}::?){1,7}([a-fA-F0-9]{1,4})$/).test(input)) | ||
@@ -488,2 +476,8 @@ return false; | ||
if(typeof(options.min) !== "undefined" && input < options.min) | ||
return new Date(options.min); | ||
if(typeof(options.max) !== "undefined" && input > options.max) | ||
return new Date(options.max); | ||
break; | ||
@@ -520,4 +514,2 @@ } | ||
} | ||
return; | ||
} | ||
@@ -529,3 +521,3 @@ | ||
"global": function(v) { | ||
if(!typeof(global) === "object" || typeof(v) === "undefined") | ||
if(global && typeof(global) !== "object" || typeof(v) === "undefined") | ||
return this; | ||
@@ -532,0 +524,0 @@ |
{ | ||
"name": "aigis", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Simple and Powerful module for strict validation", | ||
@@ -38,4 +38,4 @@ | ||
"_id": "aigis@0.0.10", | ||
"_id": "aigis@0.0.11", | ||
"_from": "aigis@" | ||
} |
@@ -52,3 +52,3 @@ `npm install aigis -g` | ||
| float | - | default, min, max, enum, abs | | ||
| date | - | default | | ||
| date | - | default, min, max | | ||
| hashTable | - | - | | ||
@@ -90,3 +90,3 @@ | array | - | max | | ||
| float | - | min, max, enum | | ||
| date | - | - | | ||
| date | - | min, max | | ||
| hashTable | - | - | | ||
@@ -93,0 +93,0 @@ | array | - | min, max | |
@@ -95,2 +95,8 @@ //----------------------------------------------------- | ||
var date = new Date(), | ||
dateNow = Date.now(), | ||
regex = /\s+/g; | ||
//-------------------------]> | ||
console.log("+-------------------------+"); | ||
@@ -101,6 +107,2 @@ console.log("|"); | ||
{ | ||
var date = new Date(), | ||
dateNow = Date.now(), | ||
regex = /\s+/g; | ||
testS(false, "boolean", undefined); | ||
@@ -231,2 +233,9 @@ testS(false, "boolean", null); | ||
testV(true, "string", "10"); | ||
testV(true, "string", "10", {"max": 2}); | ||
testV(false, "string", "100", {"max": 2}); | ||
testV(true, "string", "10", {"min": 2}); | ||
testV(false, "string", "1", {"min": 2}); | ||
testV(true, "string", "10", {"min": 2, "max": 2}); | ||
testV(false, "string", "1", {"min": 2, "max": 2}); | ||
testV(false, "string", "100", {"min": 2, "max": 2}); | ||
@@ -242,2 +251,9 @@ testV(true, "integer", 10); | ||
testV(false, "float", ""); | ||
testV(true, "float", 10, {"max": 20}); | ||
testV(false, "float", 100, {"max": 20}); | ||
testV(true, "float", 10, {"min": 10}); | ||
testV(false, "float", 1, {"min": 20}); | ||
testV(true, "float", 10, {"min": 10, "max": 20}); | ||
testV(false, "float", 1, {"min": 20, "max": 20}); | ||
testV(false, "float", 100, {"min": 20, "max": 20}); | ||
@@ -247,2 +263,4 @@ testV(false, "date", 10); | ||
testV(true, "date", new Date()); | ||
testV(true, "date", new Date(), {"min": new Date("Thu, 01 Jan 1970 00:00:00 GMT-0400")}); | ||
testV(false, "date", new Date(), {"max": new Date("Thu, 01 Jan 1970 00:00:00 GMT-0400")}); | ||
testV(false, "date", Date.now()); | ||
@@ -249,0 +267,0 @@ testV(false, "date", "23/25/2014"); |
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
49121
899