summaryrefslogtreecommitdiff
path: root/vendor/github.com/xeipuuv/gojsonschema/errors.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/xeipuuv/gojsonschema/errors.go')
-rw-r--r--vendor/github.com/xeipuuv/gojsonschema/errors.go47
1 files changed, 44 insertions, 3 deletions
diff --git a/vendor/github.com/xeipuuv/gojsonschema/errors.go b/vendor/github.com/xeipuuv/gojsonschema/errors.go
index d39f01959..2f01a1c2c 100644
--- a/vendor/github.com/xeipuuv/gojsonschema/errors.go
+++ b/vendor/github.com/xeipuuv/gojsonschema/errors.go
@@ -56,6 +56,11 @@ type (
ResultErrorFields
}
+ // ConstError. ErrorDetails: allowed
+ ConstError struct {
+ ResultErrorFields
+ }
+
// EnumError. ErrorDetails: allowed
EnumError struct {
ResultErrorFields
@@ -76,11 +81,16 @@ type (
ResultErrorFields
}
- // ItemsMustBeUniqueError. ErrorDetails: type
+ // ItemsMustBeUniqueError. ErrorDetails: type, i, j
ItemsMustBeUniqueError struct {
ResultErrorFields
}
+ // ArrayContainsError. ErrorDetails:
+ ArrayContainsError struct {
+ ResultErrorFields
+ }
+
// ArrayMinPropertiesError. ErrorDetails: min
ArrayMinPropertiesError struct {
ResultErrorFields
@@ -101,6 +111,11 @@ type (
ResultErrorFields
}
+ // InvalidPopertyNameError. ErrorDetails: property
+ InvalidPropertyNameError struct {
+ ResultErrorFields
+ }
+
// StringLengthGTEError. ErrorDetails: min
StringLengthGTEError struct {
ResultErrorFields
@@ -145,10 +160,20 @@ type (
NumberLTError struct {
ResultErrorFields
}
+
+ // ConditionThenError. ErrorDetails: -
+ ConditionThenError struct {
+ ResultErrorFields
+ }
+
+ // ConditionElseError. ErrorDetails: -
+ ConditionElseError struct {
+ ResultErrorFields
+ }
)
// newError takes a ResultError type and sets the type, context, description, details, value, and field
-func newError(err ResultError, context *jsonContext, value interface{}, locale locale, details ErrorDetails) {
+func newError(err ResultError, context *JsonContext, value interface{}, locale locale, details ErrorDetails) {
var t string
var d string
switch err.(type) {
@@ -176,6 +201,9 @@ func newError(err ResultError, context *jsonContext, value interface{}, locale l
case *InternalError:
t = "internal"
d = locale.Internal()
+ case *ConstError:
+ t = "const"
+ d = locale.Const()
case *EnumError:
t = "enum"
d = locale.Enum()
@@ -191,6 +219,9 @@ func newError(err ResultError, context *jsonContext, value interface{}, locale l
case *ItemsMustBeUniqueError:
t = "unique"
d = locale.Unique()
+ case *ArrayContainsError:
+ t = "contains"
+ d = locale.ArrayContains()
case *ArrayMinPropertiesError:
t = "array_min_properties"
d = locale.ArrayMinProperties()
@@ -203,6 +234,9 @@ func newError(err ResultError, context *jsonContext, value interface{}, locale l
case *InvalidPropertyPatternError:
t = "invalid_property_pattern"
d = locale.InvalidPropertyPattern()
+ case *InvalidPropertyNameError:
+ t = "invalid_property_name"
+ d = locale.InvalidPropertyName()
case *StringLengthGTEError:
t = "string_gte"
d = locale.StringGTE()
@@ -230,19 +264,26 @@ func newError(err ResultError, context *jsonContext, value interface{}, locale l
case *NumberLTError:
t = "number_lt"
d = locale.NumberLT()
+ case *ConditionThenError:
+ t = "condition_then"
+ d = locale.ConditionThen()
+ case *ConditionElseError:
+ t = "condition_else"
+ d = locale.ConditionElse()
}
err.SetType(t)
err.SetContext(context)
err.SetValue(value)
err.SetDetails(details)
+ err.SetDescriptionFormat(d)
details["field"] = err.Field()
if _, exists := details["context"]; !exists && context != nil {
details["context"] = context.String()
}
- err.SetDescription(formatErrorDescription(d, details))
+ err.SetDescription(formatErrorDescription(err.DescriptionFormat(), details))
}
// formatErrorDescription takes a string in the default text/template