Comparing version 1.6.1 to 1.7.0
@@ -95,3 +95,8 @@ 'use strict'; | ||
var sub = def.requireIf; | ||
if (_dotObject2.default.pick(sub, data) !== undefined && value === undefined) { | ||
if ((typeof sub === 'undefined' ? 'undefined' : _typeof(sub)) === 'object') { | ||
var field = Object.keys(sub)[0]; | ||
if (_dotObject2.default.pick(field, data) === sub[field] && value === undefined) { | ||
errors.push({ type: type, sub: sub, key: key, value: value, message: 'Value required by existing \'' + field + '\' value' }); | ||
} | ||
} else if (_dotObject2.default.pick(sub, data) !== undefined && value === undefined) { | ||
errors.push({ type: type, sub: sub, key: key, value: value, message: 'Value required because \'' + sub + '\' exists' }); | ||
@@ -113,3 +118,8 @@ } | ||
var sub = def.requireIfNot; | ||
if (_dotObject2.default.pick(sub, data) === undefined && value === undefined) { | ||
if ((typeof sub === 'undefined' ? 'undefined' : _typeof(sub)) === 'object') { | ||
var field = Object.keys(sub)[0]; | ||
if (_dotObject2.default.pick(field, data) !== sub[field] && value === undefined) { | ||
errors.push({ type: type, sub: sub, key: key, value: value, message: 'Value required because \'' + field + '\' value is not one specified' }); | ||
} | ||
} else if (_dotObject2.default.pick(sub, data) === undefined && value === undefined) { | ||
errors.push({ type: type, sub: sub, key: key, value: value, message: 'Value required because \'' + sub + '\' is undefined' }); | ||
@@ -116,0 +126,0 @@ } |
{ | ||
"name": "obey", | ||
"version": "1.6.1", | ||
"version": "1.7.0", | ||
"description": "Data modelling and validation library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
37108
877