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

@cdxoo/formik-ajv-async

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cdxoo/formik-ajv-async - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

dist/cjs/utils.js

23

dist/cjs/convert-ajv-errors.js

@@ -10,2 +10,4 @@ "use strict";

var _utils = require("./utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -21,3 +23,12 @@

) {
//console.log({ ajvErrors });
if (!(0, _utils.isArray)(ajvErrors)) {
if ((0, _utils.isAnyObject)(ajvErrors) && ajvErrors['0']) {
console.warn('ajv error list seem to be object instead of array');
ajvErrors = Object.values(ajvErrors);
} else {
throw new Error("invalid ajv errors \"".concat(ajvErrors, "\""));
}
} //console.log({ ajvErrors });
var errors = {};

@@ -37,2 +48,12 @@

if (!instancePath) {
var dataPath = err.dataPath;
if (dataPath) {
instancePath = dataPath.replace(/\./g, '/');
} else {
throw new Error("ajv error object does neither contain instancePath nor dataPath (ajv v6); error data: ".concat(JSON.stringify(err)));
}
}
if (!_jsonpointer["default"].get(errors, instancePath)) {

@@ -39,0 +60,0 @@ //var value = jsonpointer.get(data, instancePath);

24

dist/cjs/with-ajv-errors.js

@@ -10,2 +10,4 @@ "use strict";

var _utils = require("./utils");
var _convertAjvErrors = require("./convert-ajv-errors");

@@ -26,7 +28,7 @@

if (isFunction(callbackOrOptions)) {
if ((0, _utils.isFunction)(callbackOrOptions)) {
options = _objectSpread(_objectSpread({}, defaults), {}, {
callback: callbackOrOptions
});
} else if (isPlainObject(callbackOrOptions)) {
} else if ((0, _utils.isPlainObject)(callbackOrOptions)) {
options = _objectSpread(_objectSpread({}, defaults), callbackOrOptions);

@@ -49,3 +51,3 @@ } else {

return callback.apply(void 0, [values, formikBag].concat(other))["catch"](function (error) {
if (!error.response && !isAnyObject(error.response)) {
if (!error.response && !(0, _utils.isAnyObject)(error.response)) {
console.warn('error.response is not an object');

@@ -105,18 +107,2 @@ throw error;

}
};
var getType = function getType(value) {
return Object.prototype.toString.call(value).slice(8, -1);
};
var isFunction = function isFunction(value) {
return getType(value) === 'Function';
};
var isAnyObject = function isAnyObject(value) {
return getType(value) === 'Object';
};
var isPlainObject = function isPlainObject(value) {
return getType(value) === 'Object' && value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype;
};

@@ -8,5 +8,15 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }

import jsonpointer from 'jsonpointer';
import { isAnyObject, isArray } from './utils';
export var convertAjvErrors = function convertAjvErrors(ajvErrors //data
) {
//console.log({ ajvErrors });
if (!isArray(ajvErrors)) {
if (isAnyObject(ajvErrors) && ajvErrors['0']) {
console.warn('ajv error list seem to be object instead of array');
ajvErrors = Object.values(ajvErrors);
} else {
throw new Error("invalid ajv errors \"".concat(ajvErrors, "\""));
}
} //console.log({ ajvErrors });
var errors = {};

@@ -26,2 +36,12 @@

if (!instancePath) {
var dataPath = err.dataPath;
if (dataPath) {
instancePath = dataPath.replace(/\./g, '/');
} else {
throw new Error("ajv error object does neither contain instancePath nor dataPath (ajv v6); error data: ".concat(JSON.stringify(err)));
}
}
if (!jsonpointer.get(errors, instancePath)) {

@@ -28,0 +48,0 @@ //var value = jsonpointer.get(data, instancePath);

@@ -8,2 +8,3 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

import jsonpointer from 'jsonpointer';
import { isAnyObject, isPlainObject, isFunction } from './utils';
import { convertAjvErrors } from './convert-ajv-errors';

@@ -87,18 +88,2 @@ var defaults = {};

}
};
var getType = function getType(value) {
return Object.prototype.toString.call(value).slice(8, -1);
};
var isFunction = function isFunction(value) {
return getType(value) === 'Function';
};
var isAnyObject = function isAnyObject(value) {
return getType(value) === 'Object';
};
var isPlainObject = function isPlainObject(value) {
return getType(value) === 'Object' && value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype;
};
{
"name": "@cdxoo/formik-ajv-async",
"version": "0.1.0",
"version": "0.2.0",
"description": "",

@@ -54,2 +54,2 @@ "main": "dist/cjs/index.js",

}
}
}
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