fix: jsonschema integer validation (#852)

This commit is contained in:
Wei-An Yen
2024-09-21 02:22:01 +08:00
committed by GitHub
parent a5fb55321b
commit 1ec8c24ea7
2 changed files with 42 additions and 10 deletions

View File

@@ -36,6 +36,10 @@ func Validate(schema Definition, data any) bool {
_, ok := data.(bool)
return ok
case Integer:
// Golang unmarshals all numbers as float64, so we need to check if the float64 is an integer
if num, ok := data.(float64); ok {
return num == float64(int64(num))
}
_, ok := data.(int)
return ok
case Null: