You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the gojsonschema library, I encountered an issue where the schema validation does not return an error if the schema definition itself is not valid. This can lead to confusion and unexpected behavior, as the validation process proceeds without indicating that the schema is malformed.
package main
import (
"fmt""github.com/xeipuuv/gojsonschema"
)
funcmain() {
schemaLoader:=gojsonschema.NewStringLoader(`{"i am not": "real schema"}`)
documentLoader:=gojsonschema.NewStringLoader(`{"snake_snake": 3,"foo":{"bar":"baz","animals":["dog","cat","pengiun"],"number":3}}`)
result, err:=gojsonschema.Validate(schemaLoader, documentLoader)
iferr!=nil {
panic(err.Error())
}
ifresult.Valid() {
fmt.Printf("The document is valid\n")
} else {
fmt.Printf("The document is not valid. see errors :\n")
for_, desc:=rangeresult.Errors() {
fmt.Printf("- %s\n", desc)
}
}
}
Expected Behavior
The program should return an error indicating that the schema definition is not valid.
Actual Behavior
The program does not return an error for the invalid schema definition and proceeds to validate the document against the malformed schema.
Environment
gojsonschema version: v1.2.0
Go version: go1.21.5
OS: darwin/arm64
The text was updated successfully, but these errors were encountered:
When using the gojsonschema library, I encountered an issue where the schema validation does not return an error if the schema definition itself is not valid. This can lead to confusion and unexpected behavior, as the validation process proceeds without indicating that the schema is malformed.
https://go.dev/play/p/AlvO42OM74F
Expected Behavior
The program should return an error indicating that the schema definition is not valid.
Actual Behavior
The program does not return an error for the invalid schema definition and proceeds to validate the document against the malformed schema.
Environment
gojsonschema version: v1.2.0
Go version: go1.21.5
OS: darwin/arm64
The text was updated successfully, but these errors were encountered: