Closed saracen closed 4 years ago
Moving this to draft status, as I realised what I've added so far only solves one half of the problem.
This is hopefully now ready for review.
I changed %f
to %v
for printing the float values in the error reports. Although the Go type is always a float, the error message can be confusing in instances where the schema requires an integer
but the error returns something like: 5.0 must be less than 4.0
.
Brilliant, thank you.
At present, only Go float64 types are supported. Validating an integer in an interface{} of an unsupported number type currently displays an "unknown" type error.
This adds support for additional Go numeric types: uint, ints and float32s and converts them to float64's where comparisons are performed.
This is useful for cases where the interface was marshalled with an alternative json library, or in my case a yaml library, that uses ints instead of floats where it can. This also allows
jsonschema
to be used more generically against other interfaces.