Skip to content

Commit

Permalink
Support functions in object dependencies
Browse files Browse the repository at this point in the history
Fixes #1665.
  • Loading branch information
Marsup committed Nov 25, 2018
1 parent ae6031d commit 13ee9f7
Show file tree
Hide file tree
Showing 2 changed files with 261 additions and 48 deletions.
16 changes: 8 additions & 8 deletions lib/types/object/index.js
Expand Up @@ -308,7 +308,7 @@ internals.Object = class extends Any {
const hasKey = dep.key !== null;
const splitKey = hasKey && dep.key.split('.');
const localState = hasKey ? new State(splitKey[splitKey.length - 1], [...state.path, ...splitKey]) : new State(null, state.path);
const err = internals[dep.type].call(this, dep.key, hasKey && Hoek.reach(target, dep.key), dep.peers, target, localState, options);
const err = internals[dep.type].call(this, dep.key, hasKey && Hoek.reach(target, dep.key, { functions: true }), dep.peers, target, localState, options);
if (err instanceof Errors.Err) {
errors.push(err);
if (options.abortEarly) {
Expand Down Expand Up @@ -793,7 +793,7 @@ internals.with = function (key, value, peers, parent, state, options) {
for (let i = 0; i < peers.length; ++i) {

const peer = peers[i];
const keysExist = Hoek.reach(parent, peer);
const keysExist = Hoek.reach(parent, peer, { functions: true });
if (keysExist === undefined) {

return this.createError('object.with', {
Expand All @@ -815,7 +815,7 @@ internals.without = function (key, value, peers, parent, state, options) {

for (let i = 0; i < peers.length; ++i) {
const peer = peers[i];
const keysExist = Hoek.reach(parent, peer);
const keysExist = Hoek.reach(parent, peer, { functions: true });
if (keysExist !== undefined) {

return this.createError('object.without', {
Expand All @@ -834,7 +834,7 @@ internals.xor = function (key, value, peers, parent, state, options) {
const present = [];
for (let i = 0; i < peers.length; ++i) {
const peer = peers[i];
const keysExist = Hoek.reach(parent, peer);
const keysExist = Hoek.reach(parent, peer, { functions: true });
if (keysExist !== undefined) {
present.push(peer);
}
Expand Down Expand Up @@ -862,7 +862,7 @@ internals.oxor = function (key, value, peers, parent, state, options) {
const present = [];
for (let i = 0; i < peers.length; ++i) {
const peer = peers[i];
const keysExist = Hoek.reach(parent, peer);
const keysExist = Hoek.reach(parent, peer, { functions: true });
if (keysExist !== undefined) {
present.push(peer);
}
Expand All @@ -886,7 +886,7 @@ internals.or = function (key, value, peers, parent, state, options) {

for (let i = 0; i < peers.length; ++i) {
const peer = peers[i];
const keysExist = Hoek.reach(parent, peer);
const keysExist = Hoek.reach(parent, peer, { functions: true });
if (keysExist !== undefined) {
return;
}
Expand All @@ -906,7 +906,7 @@ internals.and = function (key, value, peers, parent, state, options) {
const count = peers.length;
for (let i = 0; i < count; ++i) {
const peer = peers[i];
const keysExist = Hoek.reach(parent, peer);
const keysExist = Hoek.reach(parent, peer, { functions: true });
if (keysExist === undefined) {

missing.push(peer);
Expand Down Expand Up @@ -935,7 +935,7 @@ internals.nand = function (key, value, peers, parent, state, options) {
const present = [];
for (let i = 0; i < peers.length; ++i) {
const peer = peers[i];
const keysExist = Hoek.reach(parent, peer);
const keysExist = Hoek.reach(parent, peer, { functions: true });
if (keysExist !== undefined) {

present.push(peer);
Expand Down

0 comments on commit 13ee9f7

Please sign in to comment.