Comparing version 17.0.2 to 17.1.0
@@ -13,8 +13,8 @@ 'use strict'; | ||
exports.error = function (source, stripColorCodes) { | ||
exports.error = function (stripColorCodes) { | ||
if (!source._original || | ||
typeof source._original !== 'object') { | ||
if (!this._original || | ||
typeof this._original !== 'object') { | ||
return source.details[0].message; | ||
return this.details[0].message; | ||
} | ||
@@ -26,7 +26,7 @@ | ||
const obj = Clone(source._original); | ||
const obj = Clone(this._original); | ||
for (let i = source.details.length - 1; i >= 0; --i) { // Reverse order to process deepest child first | ||
for (let i = this.details.length - 1; i >= 0; --i) { // Reverse order to process deepest child first | ||
const pos = i + 1; | ||
const error = source.details[i]; | ||
const error = this.details[i]; | ||
const path = error.path; | ||
@@ -80,5 +80,5 @@ let node = obj; | ||
for (let i = 0; i < source.details.length; ++i) { | ||
for (let i = 0; i < this.details.length; ++i) { | ||
const pos = i + 1; | ||
message = `${message}\n[${pos}] ${source.details[i].message}`; | ||
message = `${message}\n[${pos}] ${this.details[i].message}`; | ||
} | ||
@@ -85,0 +85,0 @@ |
'use strict'; | ||
const Assert = require('@hapi/hoek/lib/assert'); | ||
const Annotate = require('./annotate'); | ||
@@ -246,5 +244,2 @@ const Common = require('./common'); | ||
isJoi = true; | ||
name = 'ValidationError'; | ||
constructor(message, details, original) { | ||
@@ -257,7 +252,13 @@ | ||
annotate(stripColorCodes) { | ||
static isError(err) { | ||
Assert(Annotate.error, 'Error annotation is not supported'); | ||
return Annotate.error(this, stripColorCodes); | ||
return err instanceof exports.ValidationError; | ||
} | ||
}; | ||
exports.ValidationError.prototype.isJoi = true; | ||
exports.ValidationError.prototype.name = 'ValidationError'; | ||
exports.ValidationError.prototype.annotate = Annotate.error; |
@@ -186,2 +186,3 @@ 'use strict'; | ||
isError: Errors.ValidationError.isError, | ||
isExpression: Template.isTemplate, | ||
@@ -236,4 +237,3 @@ isRef: Ref.isRef, | ||
annotate = annotate && typeof error.annotate === 'function'; | ||
const display = annotate ? error.annotate() : error.message; | ||
const display = annotate && typeof error.annotate === 'function' ? error.annotate() : error.message; | ||
@@ -240,0 +240,0 @@ if (error instanceof Errors.ValidationError === false) { |
@@ -1,3 +0,3 @@ | ||
Copyright (c) 2012-2020, Sideway Inc, and project contributors | ||
Copyright (c) 2012-2014, Walmart. | ||
Copyright (c) 2012-2020, Sideway Inc, and project contributors | ||
Copyright (c) 2012-2014, Walmart. | ||
All rights reserved. | ||
@@ -10,2 +10,2 @@ | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
{ | ||
"name": "@hapi/joi", | ||
"description": "Object schema validation", | ||
"version": "17.0.2", | ||
"version": "17.1.0", | ||
"repository": "git://github.com/hapijs/joi", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is too big to display
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
428529
7540