Comparing version 3.0.4 to 3.0.5
@@ -0,1 +1,5 @@ | ||
### v3.0.5 (2019-04-19): | ||
* Conditional require rules (`requiredIf`, `requiredIfNot`) are now removed if a `creator` or `default` rule is defined. | ||
### v3.0.0 (2019-01-05): | ||
@@ -2,0 +6,0 @@ |
{ | ||
"name": "obey", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "Data modelling and validation library", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -139,3 +139,3 @@ /* | ||
getProps: (def, val) => { | ||
// | ||
// Require(d) alias | ||
if (def.require) { | ||
@@ -146,2 +146,24 @@ def.required = def.require | ||
} | ||
// If default or creator defined, no need for conditional requires. | ||
if (def.default || def.creator) { | ||
const conditionalRequires = ['requireIf', 'requireIfNot', 'requiredIf', 'requiredIfNot'] | ||
const rules = [] | ||
conditionalRequires.forEach((key) => { | ||
if (def[key]) { | ||
rules.push(key) | ||
delete def[key] | ||
} | ||
}) | ||
if (rules.length) { | ||
const message = [ | ||
'-----\nObey Warning: removing conditional require', | ||
`rule(s) (${rules.join(', ')}) due to 'default' or`, | ||
'\'creator\' being defined\n-----' | ||
].join(' ') | ||
console.log(message) | ||
} | ||
} | ||
// Partial and undefined | ||
@@ -148,0 +170,0 @@ if (def.opts.partial && val === undefined) return rules.props.noValPartial |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71180
844