Comparing version 0.0.15 to 0.0.16
56
index.js
@@ -5,3 +5,3 @@ //----------------------------------------------------- | ||
// Site: 666.io | ||
// Version: 0.00.015 | ||
// Version: 0.00.016 | ||
// | ||
@@ -281,34 +281,28 @@ //----------------------------------------------------- | ||
{ | ||
var gTObj = gExport.typenize, | ||
gSObj = gExport.sanitize, | ||
gVObj = gExport.validate; | ||
["set", "get", "run"] | ||
.forEach(function(name) { | ||
function buildFunc(obj, store) { | ||
switch(name) { | ||
case "set": | ||
return function(name, data) { | ||
store[name] = data; | ||
return obj; | ||
}; | ||
["set", "get", "run"] | ||
.forEach(function(name) { | ||
function buildFunc(obj, store) { | ||
switch(name) { | ||
case "set": | ||
return function(name, data) { | ||
store[name] = data; | ||
return obj; | ||
}; | ||
case "get": | ||
return function(name) { | ||
return store[name]; | ||
}; | ||
case "get": | ||
return function(name) { | ||
return store[name]; | ||
}; | ||
case "run": | ||
return function(name, data, options) { | ||
return obj(store[name], data, options); | ||
}; | ||
} | ||
case "run": | ||
return function(name, data, options) { | ||
return obj(store[name], data, options); | ||
}; | ||
} | ||
} | ||
gTObj[name] = buildFunc(gTObj, typenizeSchemaStore); | ||
gSObj[name] = buildFunc(gSObj, sanitizeSchemaStore); | ||
gVObj[name] = buildFunc(gVObj, validateSchemaStore); | ||
}); | ||
} | ||
gExport.typenize[name] = buildFunc(gExport.typenize, typenizeSchemaStore); | ||
gExport.sanitize[name] = buildFunc(gExport.sanitize, sanitizeSchemaStore); | ||
gExport.validate[name] = buildFunc(gExport.validate, validateSchemaStore); | ||
}); | ||
@@ -623,2 +617,6 @@ //------------------)> | ||
if(typeof(options.schema) === "object") { | ||
return gExport.validate(options.schema, input, options); | ||
} | ||
return typeof(input) === "object"; | ||
@@ -625,0 +623,0 @@ |
{ | ||
"name": "aigis", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "Simple and Powerful module for strict data control", | ||
@@ -40,4 +40,4 @@ | ||
"_id": "aigis@0.0.14", | ||
"_id": "aigis@0.0.16", | ||
"_from": "aigis@" | ||
} |
106
readme.md
@@ -7,51 +7,5 @@ `npm install aigis -g` | ||
var schema = { | ||
"name": { | ||
"type": "string", | ||
"rule": "required", | ||
"max": 3, | ||
"trim": true | ||
}, | ||
"status": "?string", | ||
"pts": { | ||
"use": "integer", | ||
"max": 30, | ||
"abs": true | ||
}, | ||
"data": { | ||
"type": "hashTable", | ||
"schema": { | ||
"login": "string", | ||
"password": "string", | ||
"more": { | ||
"type": "hashTable", | ||
"schema": { | ||
"someData": "string" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
data = {"name": " XX + ", "pts": "-60", "delThisField": "data"}; | ||
$typenize(schema, data); | ||
$sanitize(schema, data); | ||
$validate(schema, data); | ||
//_ $typenize: | ||
// { name: ' XX + ', pts: -60, data: { login: '', password: '', more: { someData: '' } } } | ||
//_ $sanitize: | ||
// { name: 'XX', pts: 30, data: { login: '', password: '', more: { someData: '' } } } | ||
//_ $validate: false | ||
$typenize({name: "string"}, {name: 969, "delThisField": "data"}); | ||
$sanitize({name: {type: "string", max: 2}}, {name: "Omnomnomnus"}); | ||
$validate("integer", "2"); | ||
``` | ||
@@ -136,3 +90,3 @@ | ||
| date | - | default, min, max | | ||
| hashTable | - | - | | ||
| hashTable | - | schema | | ||
| array | - | max | | ||
@@ -207,2 +161,54 @@ | json | - | - | | ||
var schema = { | ||
"name": { | ||
"type": "string", | ||
"rule": "required", | ||
"max": 3, | ||
"trim": true | ||
}, | ||
"status": "?string", | ||
"pts": { | ||
"use": "integer", | ||
"max": 30, | ||
"abs": true | ||
}, | ||
"data": { | ||
"type": "hashTable", | ||
"schema": { | ||
"login": "string", | ||
"password": "string", | ||
"more": { | ||
"type": "hashTable", | ||
"schema": { | ||
"someData": "string" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
data = {"name": " XX + ", "pts": "-60", "delThisField": "data"}; | ||
$typenize(schema, data); | ||
$sanitize(schema, data); | ||
$validate(schema, data); | ||
//_ $typenize: | ||
// { name: ' XX + ', pts: -60, data: { login: '', password: '', more: { someData: '' } } } | ||
//_ $sanitize: | ||
// { name: 'XX', pts: 30, data: { login: '', password: '', more: { someData: '' } } } | ||
//_ $validate: false | ||
//----------------------------------------------------- | ||
console.log("+-------------------------+"); | ||
@@ -209,0 +215,0 @@ console.log("| S: Custom"); |
@@ -227,2 +227,30 @@ //----------------------------------------------------- | ||
console.log("1#", $validate(schema, data)); | ||
console.log("2#", $validate(schema, data, {"errors": true})); | ||
console.log("2#", $validate(schema, data, {"errors": true})); | ||
var schema = { | ||
"info": { | ||
"rule": "hashTable", | ||
"schema": { | ||
"login": { | ||
"rule": "hashTable", | ||
"schema": { | ||
"login": "string" | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
console.log(JSON.stringify({ | ||
"T0": $validate(schema, {"info": {"login": {"login": 1}}}), | ||
"T1": $validate(schema, {"info": {}}), | ||
"T2": $validate(schema, {}), | ||
"T3": $validate(schema, {"info": {"login": {"login": 1}}}, {"errors": true}), | ||
"T4": $validate(schema, {"info": {"login": {"login": "test"}}}) | ||
}, null, "\t")); |
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
65449
1214
305