Comparing version 0.0.20 to 0.0.21
57
index.js
@@ -5,3 +5,3 @@ //----------------------------------------------------- | ||
// Site: 666.io | ||
// Version: 0.00.020 | ||
// Version: 0.00.021 | ||
// | ||
@@ -313,2 +313,6 @@ //----------------------------------------------------- | ||
.forEach(function(name) { | ||
gExport.typenize[name] = buildFunc(gExport.typenize, typenizeSchemaStore); | ||
gExport.sanitize[name] = buildFunc(gExport.sanitize, sanitizeSchemaStore); | ||
gExport.validate[name] = buildFunc(gExport.validate, validateSchemaStore); | ||
function buildFunc(obj, store) { | ||
@@ -333,6 +337,2 @@ switch(name) { | ||
} | ||
gExport.typenize[name] = buildFunc(gExport.typenize, typenizeSchemaStore); | ||
gExport.sanitize[name] = buildFunc(gExport.sanitize, sanitizeSchemaStore); | ||
gExport.validate[name] = buildFunc(gExport.validate, validateSchemaStore); | ||
}); | ||
@@ -360,3 +360,3 @@ | ||
return false; | ||
return input === 1; | ||
@@ -379,8 +379,30 @@ case "string": | ||
case "integer": | ||
if(input instanceof(Date)) { | ||
if(typeof(input.valueOf) === "function") | ||
input = input.valueOf(); else return NaN; | ||
} | ||
switch(typeof(input)) { | ||
case "undefined": return NaN; | ||
default: | ||
if(input === null) return NaN; | ||
} | ||
return parseInt(input, options.radix || 10); | ||
case "float": | ||
if(typeof(input) === "number") | ||
return input; | ||
if(input instanceof(Date)) { | ||
if(typeof(input.valueOf) === "function") | ||
input = input.valueOf(); else return NaN; | ||
} | ||
switch(typeof(input)) { | ||
case "number": return input; | ||
case "undefined": return NaN; | ||
default: | ||
if(input === null) return NaN; | ||
} | ||
return parseFloat(input); | ||
@@ -652,5 +674,4 @@ | ||
if(typeof(options.schema) === "object") { | ||
if(typeof(options.schema) === "object") | ||
return gExport.validate(options.schema, input, options); | ||
} | ||
@@ -788,3 +809,3 @@ return typeof(input) === "object"; | ||
///---)> | ||
//---)> | ||
@@ -799,3 +820,3 @@ var rgPhone = gVPhones[options.locale || "ru-RU"]; | ||
///---)> | ||
//---)> | ||
@@ -818,2 +839,7 @@ var version = options.version, | ||
case "ip": | ||
var version = options.version; | ||
return version ? $validate("ip.v" + version, input) : ($validate("ip.v4", input) || $validate("ip.v6", input)); | ||
case "ip.v4": | ||
@@ -825,7 +851,2 @@ return typeof(input) === "string" && (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/).test(input); | ||
case "ip": | ||
var version = options.version; | ||
return version ? $validate("ip.v" + version, input) : ($validate("ip.v4", input) || $validate("ip.v6", input)); | ||
//------------------------]> | ||
@@ -945,4 +966,4 @@ | ||
if(typeof(module) == "object") { | ||
if(module && typeof(module) == "object") { | ||
module.exports = $aigis.global(true); | ||
} |
{ | ||
"name": "aigis", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"description": "Simple and Powerful module for strict data control", | ||
@@ -40,4 +40,4 @@ | ||
"_id": "aigis@0.0.20", | ||
"_id": "aigis@0.0.21", | ||
"_from": "aigis@" | ||
} |
@@ -11,3 +11,3 @@ `npm install aigis -g` | ||
$sanitize({"data": {"type": "array", "schema": ["integer", "string"]}}, {"data": [6.9, "name", 100]}); | ||
$sanitize("array", [6.9, "name", "delThisElem"], {"schema": ["integer", "string"]}) | ||
``` | ||
@@ -88,8 +88,8 @@ | ||
| boolean | true: "true", "on", "yes", "1" | - | | ||
| string | - | default, max, trim, ltrim, rtrim, escape, lowercase, uppercase, onlyDigits, onlyAlphanumeric, onlyWordchar | | ||
| integer | - | default, min, max, enum, abs | | ||
| float | - | default, min, max, enum, abs | | ||
| string | - | default, enum, max, trim, ltrim, rtrim, escape, lowercase, uppercase, onlyDigits, onlyAlphanumeric, onlyWordchar | | ||
| integer | - | default, enum, min, max, abs | | ||
| float | - | default, enum, min, max, abs | | ||
| date | - | default, min, max | | ||
| hashTable | - | schema | | ||
| array | - | max | | ||
| array | - | schema, max | | ||
| json | - | - | | ||
@@ -96,0 +96,0 @@ |
@@ -16,5 +16,4 @@ //----------------------------------------------------- | ||
var data = { | ||
"data": [2.2, "name", 100] | ||
"data": [2.2, "name", "[skip/del]ThisElem"] | ||
}; | ||
@@ -31,2 +30,10 @@ | ||
var data = [6.9, "name", "delThisElem"]; | ||
console.log( | ||
$sanitize("array", data, {"schema": ["integer", "string"]}) | ||
); | ||
//-----------]> | ||
var data = { | ||
@@ -33,0 +40,0 @@ "data": [{"pts": 2.2}, "name"] |
@@ -177,2 +177,3 @@ //----------------------------------------------------- | ||
testS(NaN, "integer", ""); | ||
testS(date.valueOf(), "integer", date); | ||
@@ -186,2 +187,3 @@ testS(NaN, "float", undefined); | ||
testS(NaN, "float", ""); | ||
testS(date.valueOf(), "float", date); | ||
@@ -188,0 +190,0 @@ testS(new Date(NaN), "date", undefined); |
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
69532
1309