validator.js-validate
Advanced tools
Comparing version 1.0.0 to 1.0.1
# Changelog | ||
## [v1.0.1](https://github.com/uphold/validator.js-validate/releases/tag/v1.0.1) (2017-05-23) | ||
- Fix masking collection elements [\#3](https://github.com/uphold/validator.js-validate/pull/3) ([ricardogama](https://github.com/ricardogama)) | ||
## [v1.0.0](https://github.com/uphold/validator.js-validate/releases/tag/v1.0.0) (2017-03-28) | ||
@@ -4,0 +7,0 @@ - Prepare public release [\#2](https://github.com/uphold/validator.js-validate/pull/2) ([ricardogama](https://github.com/ricardogama)) |
@@ -30,2 +30,11 @@ 'use strict'; | ||
return (0, _lodash4.default)(constraints, (result, values, key) => { | ||
if (Array.isArray(data)) { | ||
const nodes = constraints.constraint.nodes; | ||
return data.map(element => { | ||
return nodes ? maskDataFromConstraints(element, nodes) : element; | ||
}); | ||
} | ||
// Skip non existent key. | ||
@@ -36,7 +45,8 @@ if (!data.hasOwnProperty(key)) { | ||
const hasDeeperConstraints = (0, _lodash2.default)(values); | ||
// eslint-disable-next-line no-underscore-dangle | ||
const hasDeeperConstraints = (0, _lodash2.default)(values) || values.__class__ === 'Collection'; | ||
const value = data[key]; | ||
// Skip value that is not an object and has deeper constraints. | ||
if (hasDeeperConstraints && !(0, _lodash2.default)(value)) { | ||
// Skip value that is not an object or array and has deeper constraints. | ||
if (hasDeeperConstraints && !(0, _lodash2.default)(value) && !Array.isArray(value)) { | ||
return result; | ||
@@ -67,3 +77,4 @@ } | ||
const errors = validator.validate(data, new _validator.Constraint(constraints, { deepRequired: true }), groups); | ||
const constraint = constraints instanceof _validator.Assert ? constraints : new _validator.Constraint(constraints, { deepRequired: true }); | ||
const errors = validator.validate(data, constraint, groups); | ||
@@ -70,0 +81,0 @@ if (errors === true) { |
{ | ||
"name": "validator.js-validate", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Opinionated object validation function based on validator.js", | ||
@@ -5,0 +5,0 @@ "homepage": "http://uphold.github.io/validator.js-validate", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
9563
64
1