Skip to content

Commit

Permalink
chore: update schema verification function
Browse files Browse the repository at this point in the history
  • Loading branch information
Sashwat-K committed May 14, 2024
1 parent e0925a4 commit ca5a1d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions common/general/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,19 @@ func VerifyContractWithSchema(contract string) (bool, error) {
return false, fmt.Errorf("failed to validate contract - %v", err)
}

for _, err := range report.Errors() {
fmt.Printf("- %s\n", err)
}
result := report.Valid()

if result {
return true, nil
} else {
var consolidatedErrors strings.Builder
for i, err := range report.Errors() {
if i > 0 {
consolidatedErrors.WriteString(", ")
}
consolidatedErrors.WriteString(err.String())
}

return report.Valid(), nil
return report.Valid(), fmt.Errorf("validation failed - %s", consolidatedErrors.String())
}
}
2 changes: 1 addition & 1 deletion common/general/general_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,5 +269,5 @@ func TestVerifyContractWithSchema(t *testing.T) {
t.Errorf("schema verification failed - %v", err)
}

fmt.Println(result)
assert.True(t, result)
}

0 comments on commit ca5a1d4

Please sign in to comment.