Open polarina opened 4 years ago
Hi,
The JSON schema validator incorrectly accepts the JSON strings "true" and "false" for booleans.
Example schema:
{ "$schema": "https://json-schema.org/draft/2019-09/schema", "type": "boolean" }
Example input:
"true"
Expected error:
/: "true" type should be boolean, got string
Observed behaviour: Validation passes without errors, which was not expected.
Program:
package main import ( "context" "encoding/json" "fmt" "github.com/qri-io/jsonschema" ) func main() { ctx := context.Background() var schemaData = []byte(`{ "$schema": "https://json-schema.org/draft/2019-09/schema", "type": "boolean" }`) rs := &jsonschema.Schema{} if err := json.Unmarshal(schemaData, rs); err != nil { panic("unmarshal schema: " + err.Error()) } var invalid = []byte(`"true"`) errs, err := rs.ValidateBytes(ctx, invalid) if err != nil { panic(err) } if len(errs) > 0 { fmt.Println(errs[0].Error()) } }
Hi,
The JSON schema validator incorrectly accepts the JSON strings "true" and "false" for booleans.
Example schema:
Example input:
Expected error:
Observed behaviour: Validation passes without errors, which was not expected.
Program: