Socket
Socket
Sign inDemoInstall

@orion-js/schema

Package Overview
Dependencies
Maintainers
2
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orion-js/schema - npm Package Compare versions

Comparing version 0.19.0 to 0.19.2

lib/validateKey/dotGetSchema.js

37

lib/dotGetSchema.js

@@ -7,39 +7,8 @@ 'use strict';

exports.default = function (schema, path) {
if ((0, _isNil2.default)(schema)) {
throw new Error('You need to pass a schema');
}
return dotGet({ type: schema }, path);
};
var _dotGetSchema = require('./validateKey/dotGetSchema');
var _isPlainObject = require('lodash/isPlainObject');
var _dotGetSchema2 = _interopRequireDefault(_dotGetSchema);
var _isPlainObject2 = _interopRequireDefault(_isPlainObject);
var _isNil = require('lodash/isNil');
var _isNil2 = _interopRequireDefault(_isNil);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var dotGet = function dotGet(object, path) {
if (path === '') return object;
var pathParts = path.split('.');
var first = pathParts.shift();
var remainingPath = pathParts.join('.');
var levelObject = object.type;
if (first === '$' || /^[0-9]+$/.test(first)) {
return dotGet({ type: levelObject[0] }, remainingPath);
} else if ((0, _isPlainObject2.default)(levelObject[first])) {
return dotGet(levelObject[first], remainingPath);
}
if (levelObject === 'blackbox') {
return { type: 'blackbox', optional: true };
}
return null;
};
exports.default = _dotGetSchema2.default;

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

test('return no error when the value is correct', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var info;
return regeneratorRuntime.wrap(function _callee2$(_context2) {

@@ -38,6 +39,8 @@ while (1) {

case 0:
expect(_string2.default.validate('')).toBeFalsy();
info = { currentSchema: { optional: true } };
expect(_string2.default.validate('', info)).toBeFalsy();
expect(_string2.default.validate('Nicolás')).toBeFalsy();
case 2:
case 3:
case 'end':

@@ -44,0 +47,0 @@ return _context2.stop();

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

error: 'validationError',
message: message,
message: 'Validation Error',
validationErrors: validationErrors

@@ -49,0 +49,0 @@ };

{
"name": "@orion-js/schema",
"version": "0.19.0",
"version": "0.19.2",
"main": "index.js",

@@ -27,3 +27,3 @@ "author": "nicolaslopezj",

},
"gitHead": "60cee769637a982f7b0a95554befeff79def9b26"
"gitHead": "b87ae98c03c9748afa682876871718f30028a198"
}
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