Comparing version 14.0.6 to 14.1.0
@@ -149,3 +149,3 @@ 'use strict'; | ||
if (!errors || !errors.length) { | ||
if (!errors) { | ||
return null; | ||
@@ -180,3 +180,3 @@ } | ||
if (item.context.reason && item.context.reason.length) { | ||
if (item.context.reason) { | ||
const override = processErrors(item.context.reason, item.path, item.type === 'override' ? item.message : null); | ||
@@ -183,0 +183,0 @@ if (override) { |
@@ -95,2 +95,3 @@ 'use strict'; | ||
xor: 'contains a conflict between exclusive peers {{peersWithLabels}}', | ||
oxor: 'contains a conflict between optional exclusive peers {{peersWithLabels}}', | ||
and: 'contains {{presentWithLabels}} without its required peers {{missingWithLabels}}', | ||
@@ -97,0 +98,0 @@ nand: '!!"{{mainWithLabel}}" must not exist simultaneously with {{peersWithLabels}}', |
@@ -140,7 +140,7 @@ 'use strict'; | ||
if (item.then && item.then._refs) { | ||
if (item.then && item.then._refs.length) { | ||
obj._refs.push(...item.then._refs); | ||
} | ||
if (item.otherwise && item.otherwise._refs) { | ||
if (item.otherwise && item.otherwise._refs.length) { | ||
obj._refs.push(...item.otherwise._refs); | ||
@@ -147,0 +147,0 @@ } |
@@ -620,4 +620,3 @@ 'use strict'; | ||
errors.push(this.createError(value === '' ? 'any.empty' : 'any.invalid', { value, invalids: this._invalids.values({ stripUndefined: true }) }, state, options)); | ||
if (options.abortEarly || | ||
value === undefined) { // No reason to keep validating missing value | ||
if (options.abortEarly) { | ||
@@ -624,0 +623,0 @@ return this._finalizeValue(value, originalValue, errors, state, options); |
@@ -85,3 +85,3 @@ 'use strict'; | ||
} | ||
else if (timestamp && multiplier) { | ||
else if (timestamp) { | ||
date = /^\s*$/.test(value) ? internals.invalidDate : new Date(value * multiplier); | ||
@@ -88,0 +88,0 @@ } |
@@ -506,2 +506,7 @@ 'use strict'; | ||
oxor(...peers) { | ||
return this._dependency('oxor', null, peers); | ||
} | ||
or(...peers) { | ||
@@ -835,3 +840,2 @@ | ||
if (keysExist !== undefined) { | ||
present.push(peer); | ||
@@ -858,2 +862,27 @@ } | ||
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); | ||
if (keysExist !== undefined) { | ||
present.push(peer); | ||
} | ||
} | ||
if (!present.length || | ||
present.length === 1) { | ||
return; | ||
} | ||
const context = { peers, peersWithLabels: internals.keysToLabels(this, peers) }; | ||
context.present = present; | ||
context.presentWithLabels = internals.keysToLabels(this, present); | ||
return this.createError('object.oxor', context, state, options); | ||
}; | ||
internals.or = function (key, value, peers, parent, state, options) { | ||
@@ -860,0 +889,0 @@ |
{ | ||
"name": "joi", | ||
"description": "Object schema validation", | ||
"version": "14.0.6", | ||
"version": "14.1.0", | ||
"homepage": "https://github.com/hapijs/joi", | ||
@@ -21,3 +21,3 @@ "repository": "git://github.com/hapijs/joi", | ||
"hapitoc": "1.x.x", | ||
"lab": "17.x.x" | ||
"lab": "18.x.x" | ||
}, | ||
@@ -24,0 +24,0 @@ "scripts": { |
@@ -19,3 +19,3 @@ ![joi Logo](https://raw.github.com/hapijs/joi/master/images/joi.png) | ||
# API | ||
See the detailed [API Reference](https://github.com/hapijs/joi/blob/v14.0.6/API.md). | ||
See the detailed [API Reference](https://github.com/hapijs/joi/blob/v14.1.0/API.md). | ||
@@ -22,0 +22,0 @@ # Example |
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
190021
4512