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
I saved in on playground so that you can run it and see that it results in The document is valid, while value of A is zero, which is prohibited by "exclusiveMinimum": 0 so it shouldn't validate.
The text was updated successfully, but these errors were encountered:
Helyk
changed the title
When using RawLoader, int with exclusiveMinimum 0 validates with value
When using RawLoader, int with exclusiveMinimum 0 validates with 0 value
Nov 18, 2021
Uh I thought it might be due to 0 being int's zero-value and some omitempty behavior or because of A being capital but now I tried to alter those factors and it still validates no matter what.
See example:
package main
import (
"fmt""github.com/xeipuuv/gojsonschema"
)
varschema=`{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "A": {"type": "integer", "exclusiveMinimum": 1} }, "required": ["A"]}`vardoc=struct {
Bint
}{
B: 1,
}
funcmain() {
schemaLoader:=gojsonschema.NewBytesLoader([]byte(schema))
documentLoader:=gojsonschema.NewRawLoader(doc)
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)
}
}
}
// The document is valid
I'm confused now. Why it validates? Am I doing something wrong?
Hello. Here is an example code to confirm the issue:
I saved in on playground so that you can run it and see that it results in
The document is valid
, while value ofA
is zero, which is prohibited by"exclusiveMinimum": 0
so it shouldn't validate.To compare with, ByteLoader with same data gives appropriate error.
The text was updated successfully, but these errors were encountered: