#include <jsoncons_ext/jsonschema/jsonschema.hpp>
template <typename Json>
class json_validator
json_validator(std::shared_ptr<json_schema<Json>> schema);
bool is_valid(const Json& instance) const; (1)
Json validate(const Json& instance) const; (2)
template <typename MsgReporter>
Json validate(const Json& instance, const MsgReporter& reporter) const; (3)
(1) Validates input JSON against a JSON Schema and returns false upon the first schema violation.
(2) Validates input JSON against a JSON Schema with a default error reporter that throws upon the first schema violation.
(3) Validates input JSON against a JSON Schema with a provided error reporter that is called for each schema violation.
instance | Input Json |
reporter | A function object with signature equivalent to
void fun(const validation_output& msg);which accepts an argument of type validation_output. |
(1) true
if the instance is valid, otherwise false
(2) - (3) A JSONPatch document that may be applied to the input JSON to fill in missing properties that have "default" values in the schema.
(2) Throws a validation_error for the first schema violation.
(3) reporter
is called for each schema violation