Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aigis

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aigis - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

52

index.js

@@ -5,3 +5,3 @@ //-----------------------------------------------------

// Site: 666.io
// Version: 0.00.013
// Version: 0.00.014
//

@@ -292,3 +292,3 @@ //-----------------------------------------------------

throw "[!] Validation | Unknown rule.\n" + use + " : " + JSON.stringify(options);
throw new Error("[!] Validation | Unknown rule.\n" + use + " : " + JSON.stringify(options));
}

@@ -400,3 +400,3 @@ }

throw "[!] Sanitizer | Unknown type.\n" + type + " : " + JSON.stringify(options);
throw new Error("[!] Sanitizer | Unknown type.\n" + type + " : " + JSON.stringify(options));
}

@@ -443,4 +443,2 @@ }

input = input.trim();
else if(options.ltrim)
input = input.replace(/^\s+/g, "");
else if(options.rtrim)

@@ -553,3 +551,3 @@ input = input.replace(/\s+$/g, "");

for(var field in name) {
if(!name.hasOwnProperty(field)) continue;
if(!Object.prototype.hasOwnProperty.call(name, field)) continue;

@@ -612,3 +610,3 @@ func = name[field];

if(!schema)
throw "[!] Sanitizer | schema: " + schema;
throw new Error("[!] Sanitizer | schema: " + schema);

@@ -636,6 +634,8 @@ options = options || {};

var optScenario = options.on;
var result = {};
for(var field in schema) {
if(!schema.hasOwnProperty(field)) continue;
if(!Object.prototype.hasOwnProperty.call(schema, field)) continue;

@@ -648,2 +648,6 @@ var nameFunc,

if(!schemaData) {
throw new Error("[!] Sanitizer | schemaData: " + schemaData);
}
if(typeof(schemaData) === "string") {

@@ -654,2 +658,7 @@ nameFunc = schemaData;

nameFunc = schemaData.type || schemaData.use;
if(typeof(schemaData.on) !== "undefined" && schemaData.on != optScenario)
continue;
} else {
throw new Error("[!] Sanitizer | schemaData: " + schemaData);
}

@@ -674,3 +683,3 @@

throw "[!] Sanitizer | schema: " + schema;
throw new Error("[!] Sanitizer | schema: " + schema);
},

@@ -680,3 +689,3 @@

if(!schema)
throw "[!] Validation | schema: " + schema;
throw new Error("[!] Validation | schema: " + schema);

@@ -706,14 +715,21 @@ options = options || {};

var optErrors = options.errors;
var optScenario = options.on,
optErrors = options.errors;
var result = optErrors ? null : true;
for(var field in schema) {
if(!schema.hasOwnProperty(field)) continue;
if(!Object.prototype.hasOwnProperty.call(schema, field)) continue;
var nameFunc,
schemaData = schema[field],
fieldData = data[field];
schemaData = schema[field],
fieldData = data[field];
//-----------------)>
if(!schemaData) {
throw new Error("[!] Validation | schemaData: " + schemaData);
}
if(typeof(schemaData) === "string") {

@@ -724,2 +740,7 @@ nameFunc = schemaData;

nameFunc = schemaData.rule || schemaData.use;
if(typeof(schemaData.on) !== "undefined" && schemaData.on != optScenario)
continue;
} else {
throw new Error("[!] Validation | schemaData: " + schemaData);
}

@@ -736,2 +757,3 @@

if(!validation(nameFunc, fieldData, schemaData, data)) {

@@ -758,3 +780,3 @@ if(optErrors) {

throw "[!] Validation | schema: " + schema;
throw new Error("[!] Validation | schema: " + schema);
}

@@ -761,0 +783,0 @@ };

{
"name": "aigis",
"version": "0.0.13",
"version": "0.0.14",
"description": "Simple and Powerful module for strict validation",

@@ -38,4 +38,4 @@

"_id": "aigis@0.0.13",
"_id": "aigis@0.0.14",
"_from": "aigis@"
}

@@ -27,2 +27,3 @@ `npm install aigis -g`

#### Module

@@ -41,8 +42,26 @@

| Options | Desc | Val |
|-------------|-------------|-------------|
| | - ||
| errors | Validate method returns null or an array of errors | true/false (def: false)|
| on | Scenario | - |
```js
//_ Error: structure
{
"field": field,
"use": nameFunc,
"input": fieldData
}
```
#### Sanitize
| Type | Desc | Val |
|-------------|-------------|-------------|
|-------------|-------------|-------------|
| | - ||
| | ALL (If `schema` is HashTable) | on |
| custom | - | - |

@@ -60,3 +79,3 @@ | boolean | true: "true", "on", "yes", "1" | - |

String:
default (stop chain) -> enum (stop chain) -> [trim|ltrim|rtrim] -> max -> only[Digits|Alphanumeric|Wordchar] -> [trim|ltrim|rtrim] -> [uppercase|lowercase] -> escape
default (stop chain) -> enum (stop chain) -> [l|r]trim -> max -> only[Digits|Alphanumeric|Wordchar] -> [r]trim -> [uppercase|lowercase] -> escape

@@ -70,22 +89,6 @@ Number:

| Options | Desc | Val |
|-------------|-------------|-------------|
| | - ||
| errors | Validate method returns null or an array of errors | true/false (def: false)|
```js
//_ Error: structure
{
"field": field,
"use": nameFunc,
"input": fieldData
}
```
| Rule | Desc | Params/Options |
|-------------|-------------|-------------|
| | - ||
| | ALL (If `schema` is HashTable) | on |
| null | - | - |

@@ -92,0 +95,0 @@ | nan | - | - |

@@ -46,2 +46,29 @@ //-----------------------------------------------------

function testX(exp, data) {
count.s++;
var result = true,
args = Array.prototype.slice.call(arguments, 1);
try {
if(typeof(exp) === "number")
rA.strictEqualNumber(data, exp);
else if(exp instanceof Date)
rA.strictEqualDate(data, exp);
else if(typeof(exp) === "object" || exp !== null)
rA.deepEqual(data, exp);
else
rA.strictEqual(data, exp);
} catch(e) {
result = false;
console.log(args);
console.log(e);
console.log("\n");
}
if(!result)
console.log("|%s|> T%s ", result ? "+" : "-", count.s);
}
function testS(exp, data) {

@@ -100,2 +127,6 @@ count.s++;

var schema = {
"pts": {"use": "integer", "max": 30, "abs": true, "on": "update"}
};
//-------------------------]>

@@ -108,2 +139,12 @@

{
{
var result;
result = $sanitize(schema, {"pts": 50}, {"on": ""});
testX(undefined, result.pts, "result.pts");
result = $sanitize(schema, {"pts": 50}, {"on": "update"});
testX(30, result.pts, "result.pts");
}
testS(false, "boolean", undefined);

@@ -201,2 +242,13 @@ testS(false, "boolean", null);

{
{
var result;
result = $validate(schema, {"pts": 50}, {"on": ""});
testX(true, result, "result.pts");
result = $validate(schema, {"pts": 50}, {"on": "update"});
testX(false, result, "result.pts");
}
[

@@ -203,0 +255,0 @@ "finite",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc