Skip to content

Commit

Permalink
Merge pull request #265 from per1234/schema-validation-error-handling
Browse files Browse the repository at this point in the history
Panic on unexpected schema validation error
  • Loading branch information
per1234 committed Sep 1, 2021
2 parents 3b6da1c + 31c699b commit 4e6c832
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/rule/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,19 @@ func Compile(schemaFilename string, referencedSchemaFilenames []string, dataLoad
// jsonschema.ValidationError object otherwise.
func Validate(instanceInterface map[string]interface{}, schemaObject Schema) ValidationResult {
validationError := schemaObject.Compiled.ValidateInterface(instanceInterface)
result, _ := validationError.(*jsonschema.ValidationError)
validationResult := ValidationResult{
Result: result,
Result: nil,
dataLoader: schemaObject.dataLoader,
}

if validationError != nil {
result, ok := validationError.(*jsonschema.ValidationError)
if !ok {
panic(validationError)
}
validationResult.Result = result
}

if validationResult.Result == nil {
logrus.Debug("Schema validation of instance document passed")
} else {
Expand Down

0 comments on commit 4e6c832

Please sign in to comment.