danielaparker / jsoncons

A C++, header-only library for constructing JSON and JSON-like data formats, with JSON Pointer, JSON Patch, JSON Schema, JSONPath, JMESPath, CSV, MessagePack, CBOR, BSON, UBJSON
https://danielaparker.github.io/jsoncons
Other
697 stars 160 forks source link

josnschema validator: Error message for maximum value does not contain the actual maximum value. #474

Closed Draktul closed 8 months ago

Draktul commented 8 months ago

In the extension jsonschema: The error message while checking the maximum value does not contain the actual maximum value. Instead the current value is printed twice.

Error message if the maximum value is surpassed: "#/latitude: 1152.37392 exceeds maximum of 1152.373920"

Expected: "#/latitude: 1152.37392 exceeds maximum of 90.0000" << 90 is the maximum value defined in the schema

Solution: in function _dovalidate in class _maximumvalidator in file keywords.hpp

if (value > value_)
            {
                reporter.error(validation_output("maximum", 
                    this->schema_path(), 
                    instance_location.to_uri_fragment(), 
                    instance.template as<std::string>() + " exceeds maximum of " + std::to_string(value)));
            } 

change std::to_string(value) to std::tostring(**value**)

thanks for this great Framework

danielaparker commented 8 months ago

You're right, fixed on master

Draktul commented 8 months ago

Thank you :)