Socket
Socket
Sign inDemoInstall

validate-value

Package Overview
Dependencies
Maintainers
4
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

validate-value - npm Package Compare versions

Comparing version 4.1.0 to 5.0.0

9

dist/Value.js

@@ -28,3 +28,7 @@ 'use strict';

value: function validate(value) {
var valueName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value';
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$valueName = _ref.valueName,
valueName = _ref$valueName === void 0 ? 'value' : _ref$valueName,
_ref$separator = _ref.separator,
separator = _ref$separator === void 0 ? '.' : _ref$separator;

@@ -48,3 +52,4 @@ if (value === undefined) {

path = _errors$.path;
var error = new Error("".concat(message, " (at ").concat(valueName).concat(path.substring(1), ")."));
var updatedPath = "".concat(valueName).concat(path.substring(1).replace(/\./, separator));
var error = new Error("".concat(message, " (at ").concat(updatedPath, ")."));
error.origins = errors;

@@ -51,0 +56,0 @@ throw error;

{
"name": "validate-value",
"version": "4.1.0",
"version": "5.0.0",
"description": "validate-value validates values against JSON schemas.",

@@ -5,0 +5,0 @@ "contributors": [

@@ -48,3 +48,3 @@ # validate-value

By default, the error message uses `value` as identifier for the object that is validated, but sometimes you may want to change this. Therefor, provide the desired identifier as second parameter to the `validate` function:
By default, the error message uses `value` as identifier and `.` as the separator for the object that is validated, but sometimes you may want to change this. Therefor, provide the desired identifier and separator as second parameter to the `validate` function:

@@ -58,3 +58,3 @@ ```javascript

try {
value.validate(user, 'person');
value.validate(user, { valueName: 'person', separator: '/' });
} catch (ex) {

@@ -61,0 +61,0 @@ // ...

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

validate (value, valueName = 'value') {
validate (value, { valueName = 'value', separator = '.' } = {}) {
if (value === undefined) {

@@ -35,4 +35,6 @@ throw new Error('Value is missing.');

const error = new Error(`${message} (at ${valueName}${path.substring(1)}).`);
const updatedPath = `${valueName}${path.substring(1).replace(/\./, separator)}`;
const error = new Error(`${message} (at ${updatedPath}).`);
error.origins = errors;

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

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

username: 'Jane Doe'
}, 'root');
}, { valueName: 'root', separator: '/' });
}).is.throwing(ex =>
ex.message === 'Missing required property: password (at root.password).' &&
ex.message === 'Missing required property: password (at root/password).' &&
Array.isArray(ex.origins));

@@ -65,0 +65,0 @@ });

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