Socket
Socket
Sign inDemoInstall

ajv

Package Overview
Dependencies
Maintainers
2
Versions
355
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajv - npm Package Compare versions

Comparing version 6.12.2 to 6.12.3

3

lib/ajv.d.ts

@@ -186,2 +186,3 @@ declare var ajv: {

strictKeywords?: boolean | 'log';
strictNumbers?: boolean;
async?: boolean | string;

@@ -200,3 +201,3 @@ transpile?: string | ((code: string) => string);

sourceCode?: boolean;
processCode?: (code: string) => string;
processCode?: (code: string, schema: object) => string;
cache?: object;

@@ -203,0 +204,0 @@ logger?: CustomLogger | false;

'use strict';
// do NOT remove this file - it would break pre-compiled schemas
// https://github.com/epoberezkin/ajv/issues/889
// https://github.com/ajv-validator/ajv/issues/889
module.exports = require('fast-deep-equal');

@@ -116,3 +116,3 @@ 'use strict';

if (opts.processCode) sourceCode = opts.processCode(sourceCode);
if (opts.processCode) sourceCode = opts.processCode(sourceCode, _schema);
// console.log('\n\n\n *** \n', JSON.stringify(sourceCode));

@@ -119,0 +119,0 @@ var validate;

@@ -16,4 +16,2 @@ 'use strict';

varReplace: varReplace,
cleanUpCode: cleanUpCode,
finalCleanUpCode: finalCleanUpCode,
schemaHasRules: schemaHasRules,

@@ -40,3 +38,3 @@ schemaHasRulesExcept: schemaHasRulesExcept,

function checkDataType(dataType, data, negate) {
function checkDataType(dataType, data, strictNumbers, negate) {
var EQUAL = negate ? ' !== ' : ' === '

@@ -54,3 +52,6 @@ , AND = negate ? ' || ' : ' && '

NOT + '(' + data + ' % 1)' +
AND + data + EQUAL + data + ')';
AND + data + EQUAL + data +
(strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
case 'number': return '(typeof ' + data + EQUAL + '"' + dataType + '"' +
(strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';

@@ -61,5 +62,5 @@ }

function checkDataTypes(dataTypes, data) {
function checkDataTypes(dataTypes, data, strictNumbers) {
switch (dataTypes.length) {
case 1: return checkDataType(dataTypes[0], data, true);
case 1: return checkDataType(dataTypes[0], data, strictNumbers, true);
default:

@@ -77,3 +78,3 @@ var code = '';

for (var t in types)
code += (code ? ' && ' : '' ) + checkDataType(t, data, true);
code += (code ? ' && ' : '' ) + checkDataType(t, data, strictNumbers, true);

@@ -144,38 +145,2 @@ return code;

var EMPTY_ELSE = /else\s*{\s*}/g
, EMPTY_IF_NO_ELSE = /if\s*\([^)]+\)\s*\{\s*\}(?!\s*else)/g
, EMPTY_IF_WITH_ELSE = /if\s*\(([^)]+)\)\s*\{\s*\}\s*else(?!\s*if)/g;
function cleanUpCode(out) {
return out.replace(EMPTY_ELSE, '')
.replace(EMPTY_IF_NO_ELSE, '')
.replace(EMPTY_IF_WITH_ELSE, 'if (!($1))');
}
var ERRORS_REGEXP = /[^v.]errors/g
, REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g
, REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g
, RETURN_VALID = 'return errors === 0;'
, RETURN_TRUE = 'validate.errors = null; return true;'
, RETURN_ASYNC = /if \(errors === 0\) return data;\s*else throw new ValidationError\(vErrors\);/
, RETURN_DATA_ASYNC = 'return data;'
, ROOTDATA_REGEXP = /[^A-Za-z_$]rootData[^A-Za-z0-9_$]/g
, REMOVE_ROOTDATA = /if \(rootData === undefined\) rootData = data;/;
function finalCleanUpCode(out, async) {
var matches = out.match(ERRORS_REGEXP);
if (matches && matches.length == 2) {
out = async
? out.replace(REMOVE_ERRORS_ASYNC, '')
.replace(RETURN_ASYNC, RETURN_DATA_ASYNC)
: out.replace(REMOVE_ERRORS, '')
.replace(RETURN_VALID, RETURN_TRUE);
}
matches = out.match(ROOTDATA_REGEXP);
if (!matches || matches.length !== 3) return out;
return out.replace(REMOVE_ROOTDATA, '');
}
function schemaHasRules(schema, rules) {

@@ -259,3 +224,3 @@ if (typeof schema == 'boolean') return !schema;

if (a == '""') return b;
return (a + ' + ' + b).replace(/' \+ '/g, '');
return (a + ' + ' + b).replace(/([^\\])' \+ '/g, '$1');
}

@@ -262,0 +227,0 @@

@@ -41,3 +41,3 @@ 'use strict';

schema,
{ $ref: 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' }
{ $ref: 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
]

@@ -44,0 +44,0 @@ };

@@ -6,3 +6,3 @@ 'use strict';

module.exports = {
$id: 'https://github.com/epoberezkin/ajv/blob/master/lib/definition_schema.js',
$id: 'https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js',
definitions: {

@@ -9,0 +9,0 @@ simpleTypes: metaSchema.definitions.simpleTypes

@@ -27,2 +27,8 @@ 'use strict';

$errorKeyword = undefined;
if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
throw new Error($keyword + ' must be number');
}
if (!($isDataExcl || $schemaExcl === undefined || typeof $schemaExcl == 'number' || typeof $schemaExcl == 'boolean')) {
throw new Error($exclusiveKeyword + ' must be number or boolean');
}
if ($isDataExcl) {

@@ -29,0 +35,0 @@ var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),

@@ -20,2 +20,5 @@ 'use strict';

}
if (!($isData || typeof $schema == 'number')) {
throw new Error($keyword + ' must be number');
}
var $op = $keyword == 'maxItems' ? '>' : '<';

@@ -22,0 +25,0 @@ out += 'if ( ';

@@ -20,2 +20,5 @@ 'use strict';

}
if (!($isData || typeof $schema == 'number')) {
throw new Error($keyword + ' must be number');
}
var $op = $keyword == 'maxLength' ? '>' : '<';

@@ -22,0 +25,0 @@ out += 'if ( ';

@@ -20,2 +20,5 @@ 'use strict';

}
if (!($isData || typeof $schema == 'number')) {
throw new Error($keyword + ' must be number');
}
var $op = $keyword == 'maxProperties' ? '>' : '<';

@@ -22,0 +25,0 @@ out += 'if ( ';

@@ -41,4 +41,3 @@ 'use strict';

}
out = it.util.cleanUpCode(out);
return out;
}

@@ -67,3 +67,2 @@ 'use strict';

}
out = it.util.cleanUpCode(out);
} else {

@@ -70,0 +69,0 @@ if ($breakOnError) {

@@ -80,4 +80,3 @@ 'use strict';

}
out = it.util.cleanUpCode(out);
return out;
}

@@ -20,2 +20,3 @@ 'use strict';

for ($property in $schema) {
if ($property == '__proto__') continue;
var $sch = $schema[$property];

@@ -167,4 +168,3 @@ var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;

}
out = it.util.cleanUpCode(out);
return out;
}

@@ -97,3 +97,2 @@ 'use strict';

}
out = it.util.cleanUpCode(out);
} else {

@@ -100,0 +99,0 @@ if ($breakOnError) {

@@ -139,4 +139,3 @@ 'use strict';

}
out = it.util.cleanUpCode(out);
return out;
}

@@ -19,2 +19,5 @@ 'use strict';

}
if (!($isData || typeof $schema == 'number')) {
throw new Error($keyword + ' must be number');
}
out += 'var division' + ($lvl) + ';if (';

@@ -21,0 +24,0 @@ if ($isData) {

@@ -21,5 +21,5 @@ 'use strict';

$dataProperties = 'dataProperties' + $lvl;
var $schemaKeys = Object.keys($schema || {}),
var $schemaKeys = Object.keys($schema || {}).filter(notProto),
$pProperties = it.schema.patternProperties || {},
$pPropertyKeys = Object.keys($pProperties),
$pPropertyKeys = Object.keys($pProperties).filter(notProto),
$aProperties = it.schema.additionalProperties,

@@ -34,3 +34,9 @@ $someProperties = $schemaKeys.length || $pPropertyKeys.length,

var $required = it.schema.required;
if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) var $requiredHash = it.util.toHash($required);
if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) {
var $requiredHash = it.util.toHash($required);
}
function notProto(p) {
return p !== '__proto__';
}
out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;';

@@ -330,4 +336,3 @@ if ($ownProperties) {

}
out = it.util.cleanUpCode(out);
return out;
}

@@ -80,4 +80,3 @@ 'use strict';

}
out = it.util.cleanUpCode(out);
return out;
}

@@ -32,3 +32,3 @@ 'use strict';

var $method = 'checkDataType' + ($typeIsArray ? 's' : '');
out += ' if (' + (it.util[$method]($itemType, 'item', true)) + ') continue; ';
out += ' if (' + (it.util[$method]($itemType, 'item', it.opts.strictNumbers, true)) + ') continue; ';
if ($typeIsArray) {

@@ -35,0 +35,0 @@ out += ' if (typeof item == \'string\') item = \'"\' + item; ';

@@ -152,3 +152,3 @@ 'use strict';

$method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
out += ' if (' + (it.util[$method]($typeSchema, $data, true)) + ') { ';
out += ' if (' + (it.util[$method]($typeSchema, $data, it.opts.strictNumbers, true)) + ') { ';
if ($coerceToTypes) {

@@ -306,3 +306,3 @@ var $dataType = 'dataType' + $lvl,

if ($rulesGroup.type) {
out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data)) + ') { ';
out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data, it.opts.strictNumbers)) + ') { ';
}

@@ -475,6 +475,2 @@ if (it.opts.useDefaults) {

}
out = it.util.cleanUpCode(out);
if ($top) {
out = it.util.finalCleanUpCode(out, $async);
}

@@ -481,0 +477,0 @@ function $shouldUseGroup($rulesGroup) {

@@ -49,3 +49,3 @@ 'use strict';

metaSchema,
{ '$ref': 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' }
{ '$ref': 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
]

@@ -52,0 +52,0 @@ };

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#",
"$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
"description": "Meta-schema for $data reference (JSON Schema extension proposal)",

@@ -5,0 +5,0 @@ "type": "object",

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-secure.json#",
"$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/json-schema-secure.json#",
"title": "Meta-schema for the security assessment of JSON Schemas",

@@ -5,0 +5,0 @@ "description": "If a JSON Schema fails validation against this meta-schema, it may be unsafe to validate untrusted data",

{
"name": "ajv",
"version": "6.12.2",
"version": "6.12.3",
"description": "Another JSON Schema Validator",

@@ -45,3 +45,3 @@ "main": "lib/ajv.js",

"type": "git",
"url": "https://github.com/epoberezkin/ajv.git"
"url": "https://github.com/ajv-validator/ajv.git"
},

@@ -61,5 +61,5 @@ "keywords": [

"bugs": {
"url": "https://github.com/epoberezkin/ajv/issues"
"url": "https://github.com/ajv-validator/ajv/issues"
},
"homepage": "https://github.com/epoberezkin/ajv",
"homepage": "https://github.com/ajv-validator/ajv",
"tonicExampleFilename": ".tonic_example.js",

@@ -81,3 +81,3 @@ "dependencies": {

"dot": "^1.0.3",
"eslint": "^6.0.0",
"eslint": "^7.3.1",
"gh-pages-generator": "^0.2.3",

@@ -93,7 +93,7 @@ "glob": "^7.0.0",

"karma-sauce-launcher": "^4.1.3",
"mocha": "^7.0.1",
"mocha": "^8.0.1",
"nyc": "^15.0.0",
"pre-commit": "^1.1.1",
"require-globify": "^1.3.0",
"typescript": "^2.8.3",
"typescript": "^3.9.5",
"uglify-js": "^3.6.9",

@@ -105,3 +105,7 @@ "watch": "^1.0.0"

"url": "https://opencollective.com/ajv"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/epoberezkin"
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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