Socket
Socket
Sign inDemoInstall

better-ajv-errors

Package Overview
Dependencies
26
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.0 to 0.8.0

6

CHANGELOG.md
# better-ajv-errors
## 0.8.0
### Minor Changes
- 8846dda: ajv 8 support
## 0.7.0

@@ -4,0 +10,0 @@

4

lib/legacy/helpers.js

@@ -42,5 +42,5 @@ "use strict";

ajvErrors.forEach(function (ajvError) {
var dataPath = ajvError.dataPath; // `dataPath === ''` is root
var instancePath = typeof ajvError.instancePath !== 'undefined' ? ajvError.instancePath : ajvError.dataPath; // `dataPath === ''` is root
var paths = dataPath === '' ? [''] : dataPath.match(JSON_POINTERS_REGEX);
var paths = instancePath === '' ? [''] : instancePath.match(JSON_POINTERS_REGEX);
paths && paths.reduce(function (obj, path, i) {

@@ -47,0 +47,0 @@ obj.children[path] = obj.children[path] || {

@@ -40,15 +40,12 @@ "use strict";

message = _this$options.message,
dataPath = _this$options.dataPath,
params = _this$options.params;
var output = [_chalk.default`{red {bold ADDTIONAL PROPERTY} ${message}}\n`];
return output.concat(this.getCodeFrame(_chalk.default`😲 {magentaBright ${params.additionalProperty}} is not expected to be here!`, `${dataPath}/${params.additionalProperty}`));
return output.concat(this.getCodeFrame(_chalk.default`😲 {magentaBright ${params.additionalProperty}} is not expected to be here!`, `${this.instancePath}/${params.additionalProperty}`));
};
_proto.getError = function getError() {
var _this$options2 = this.options,
params = _this$options2.params,
dataPath = _this$options2.dataPath;
return Object.assign({}, this.getLocation(`${dataPath}/${params.additionalProperty}`), {
error: `${this.getDecoratedPath(dataPath)} Property ${params.additionalProperty} is not expected to be here`,
path: dataPath
var params = this.options.params;
return Object.assign({}, this.getLocation(`${this.instancePath}/${params.additionalProperty}`), {
error: `${this.getDecoratedPath()} Property ${params.additionalProperty} is not expected to be here`,
path: this.instancePath
});

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

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _codeFrame = require("@babel/code-frame");

@@ -35,3 +39,3 @@

if (dataPath === void 0) {
dataPath = this.options.dataPath;
dataPath = this.instancePath;
}

@@ -54,3 +58,3 @@

if (dataPath === void 0) {
dataPath = this.options.dataPath;
dataPath = this.instancePath;
}

@@ -64,3 +68,3 @@

if (dataPath === void 0) {
dataPath = this.options.dataPath;
dataPath = this.instancePath;
}

@@ -72,3 +76,7 @@

});
};
}
/**
* @return {string}
*/
;

@@ -83,2 +91,8 @@ _proto.print = function print() {

(0, _createClass2.default)(BaseValidationError, [{
key: "instancePath",
get: function get() {
return typeof this.options.instancePath !== 'undefined' ? this.options.instancePath : this.options.dataPath;
}
}]);
return BaseValidationError;

@@ -85,0 +99,0 @@ }();

@@ -40,7 +40,6 @@ "use strict";

keyword = _this$options2.keyword,
message = _this$options2.message,
dataPath = _this$options2.dataPath;
message = _this$options2.message;
return Object.assign({}, this.getLocation(), {
error: `${this.getDecoratedPath(dataPath)}: ${keyword} ${message}`,
path: dataPath
error: `${this.getDecoratedPath()}: ${keyword} ${message}`,
path: this.instancePath
});

@@ -47,0 +46,0 @@ };

@@ -53,8 +53,8 @@ "use strict";

message = _this$options2.message,
dataPath = _this$options2.dataPath,
params = _this$options2.params;
var bestMatch = this.findBestMatch();
var allowedValues = params.allowedValues.join(', ');
var output = Object.assign({}, this.getLocation(), {
error: `${this.getDecoratedPath(dataPath)} ${message}: ${params.allowedValues.join(', ')}`,
path: dataPath
error: `${this.getDecoratedPath()} ${message}: ${allowedValues}`,
path: this.instancePath
});

@@ -70,6 +70,4 @@

_proto.findBestMatch = function findBestMatch() {
var _this$options3 = this.options,
dataPath = _this$options3.dataPath,
allowedValues = _this$options3.params.allowedValues;
var currentValue = dataPath === '' ? this.data : _jsonpointer.default.get(this.data, dataPath);
var allowedValues = this.options.params.allowedValues;
var currentValue = this.instancePath === '' ? this.data : _jsonpointer.default.get(this.data, this.instancePath);

@@ -76,0 +74,0 @@ if (!currentValue) {

@@ -31,3 +31,3 @@ "use strict";

if (dataPath === void 0) {
dataPath = this.options.dataPath;
dataPath = this.instancePath;
}

@@ -52,8 +52,6 @@

_proto.getError = function getError() {
var _this$options2 = this.options,
message = _this$options2.message,
dataPath = _this$options2.dataPath;
var message = this.options.message;
return Object.assign({}, this.getLocation(), {
error: `${this.getDecoratedPath(dataPath)} ${message}`,
path: dataPath
error: `${this.getDecoratedPath()} ${message}`,
path: this.instancePath
});

@@ -60,0 +58,0 @@ };

@@ -22,7 +22,5 @@ "use strict";

ajvErrors.forEach(ajvError => {
const {
dataPath
} = ajvError; // `dataPath === ''` is root
const instancePath = typeof ajvError.instancePath !== 'undefined' ? ajvError.instancePath : ajvError.dataPath; // `dataPath === ''` is root
const paths = dataPath === '' ? [''] : dataPath.match(JSON_POINTERS_REGEX);
const paths = instancePath === '' ? [''] : instancePath.match(JSON_POINTERS_REGEX);
paths && paths.reduce((obj, path, i) => {

@@ -29,0 +27,0 @@ obj.children[path] = obj.children[path] || {

@@ -23,7 +23,6 @@ "use strict";

message,
dataPath,
params
} = this.options;
const output = [_chalk.default`{red {bold ADDTIONAL PROPERTY} ${message}}\n`];
return output.concat(this.getCodeFrame(_chalk.default`😲 {magentaBright ${params.additionalProperty}} is not expected to be here!`, `${dataPath}/${params.additionalProperty}`));
return output.concat(this.getCodeFrame(_chalk.default`😲 {magentaBright ${params.additionalProperty}} is not expected to be here!`, `${this.instancePath}/${params.additionalProperty}`));
}

@@ -33,8 +32,7 @@

const {
params,
dataPath
params
} = this.options;
return Object.assign({}, this.getLocation(`${dataPath}/${params.additionalProperty}`), {
error: `${this.getDecoratedPath(dataPath)} Property ${params.additionalProperty} is not expected to be here`,
path: dataPath
return Object.assign({}, this.getLocation(`${this.instancePath}/${params.additionalProperty}`), {
error: `${this.getDecoratedPath()} Property ${params.additionalProperty} is not expected to be here`,
path: this.instancePath
});

@@ -41,0 +39,0 @@ }

@@ -26,3 +26,3 @@ "use strict";

getLocation(dataPath = this.options.dataPath) {
getLocation(dataPath = this.instancePath) {
const {

@@ -41,3 +41,3 @@ isIdentifierLocation,

getDecoratedPath(dataPath = this.options.dataPath) {
getDecoratedPath(dataPath = this.instancePath) {
const decoratedPath = (0, _json.getDecoratedDataPath)(this.jsonAst, dataPath);

@@ -47,3 +47,3 @@ return decoratedPath;

getCodeFrame(message, dataPath = this.options.dataPath) {
getCodeFrame(message, dataPath = this.instancePath) {
return (0, _codeFrame.codeFrameColumns)(this.jsonRaw, this.getLocation(dataPath), {

@@ -54,3 +54,11 @@ highlightCode: true,

}
/**
* @return {string}
*/
get instancePath() {
return typeof this.options.instancePath !== 'undefined' ? this.options.instancePath : this.options.dataPath;
}
print() {

@@ -57,0 +65,0 @@ throw new Error(`Implement the 'print' method inside ${this.constructor.name}!`);

@@ -25,8 +25,7 @@ "use strict";

keyword,
message,
dataPath
message
} = this.options;
return Object.assign({}, this.getLocation(), {
error: `${this.getDecoratedPath(dataPath)}: ${keyword} ${message}`,
path: dataPath
error: `${this.getDecoratedPath()}: ${keyword} ${message}`,
path: this.instancePath
});

@@ -33,0 +32,0 @@ }

@@ -34,9 +34,9 @@ "use strict";

message,
dataPath,
params
} = this.options;
const bestMatch = this.findBestMatch();
const allowedValues = params.allowedValues.join(', ');
const output = Object.assign({}, this.getLocation(), {
error: `${this.getDecoratedPath(dataPath)} ${message}: ${params.allowedValues.join(', ')}`,
path: dataPath
error: `${this.getDecoratedPath()} ${message}: ${allowedValues}`,
path: this.instancePath
});

@@ -53,3 +53,2 @@

const {
dataPath,
params: {

@@ -59,3 +58,3 @@ allowedValues

} = this.options;
const currentValue = dataPath === '' ? this.data : _jsonpointer.default.get(this.data, dataPath);
const currentValue = this.instancePath === '' ? this.data : _jsonpointer.default.get(this.data, this.instancePath);

@@ -62,0 +61,0 @@ if (!currentValue) {

@@ -13,3 +13,3 @@ "use strict";

class RequiredValidationError extends _base.default {
getLocation(dataPath = this.options.dataPath) {
getLocation(dataPath = this.instancePath) {
const {

@@ -34,8 +34,7 @@ start

const {
message,
dataPath
message
} = this.options;
return Object.assign({}, this.getLocation(), {
error: `${this.getDecoratedPath(dataPath)} ${message}`,
path: dataPath
error: `${this.getDecoratedPath()} ${message}`,
path: this.instancePath
});

@@ -42,0 +41,0 @@ }

{
"name": "better-ajv-errors",
"version": "0.7.0",
"version": "0.8.0",
"description": "JSON Schema validation for Human",

@@ -54,2 +54,3 @@ "repository": "atlassian/better-ajv-errors",

"@changesets/cli": "^1.3.0",
"ajv": "^8.5.0",
"babel-core": "^7.0.0-bridge.0",

@@ -72,3 +73,3 @@ "babel-jest": "^24.9.0",

"peerDependencies": {
"ajv": "4.11.8 - 6"
"ajv": "4.11.8 - 8"
},

@@ -75,0 +76,0 @@ "jest": {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡ī¸ by Socket Inc