We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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()) } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
The JSON schema validator incorrectly accepts the JSON strings "true" and "false" for booleans.
Example schema:
Example input:
"true"
Expected error:
Observed behaviour:
Validation passes without errors, which was not expected.
Program:
The text was updated successfully, but these errors were encountered: