1#include <nlohmann/json-schema.hpp>
10 std::cerr << "Failed: '" << a << "' != '" << b << "'\n";
23{
24 "$schema": "http://json-schema.org/draft-07/schema#",
25 "title": "A person",
26 "properties": {
27 "name": {
28 "description": "Name",
29 "type": "string"
30 },
31 "age": {
32 "description": "Age of the person",
33 "type": "number",
34 "minimum": 2,
35 "maximum": 200
36 },
37 "phones": {
38 "type": "array",
39 "items": {
40 "type": "number"
41 }
42 }
43 },
44 "required": [
45 "name",
46 "age"
47 ],
48 "additionalProperties": false,
49 "type": "object"
50})"_json;
54 void error(
const nlohmann::json::json_pointer &ptr,
const json &instance,
const std::string &message)
override
57 std::cerr <<
"ERROR: '" << ptr <<
"' - '" << instance <<
"': " << message <<
"\n";
104 {
"phones", {1234,
"223"}},
115 {
"post-code", 12345},
void error(const nlohmann::json::json_pointer &ptr, const json &instance, const std::string &message) override
std::vector< nlohmann::json::json_pointer > failed_pointers
void error(const json::json_pointer &, const json &, const std::string &) override
json_validator(const json &, schema_loader=nullptr, format_checker=nullptr, content_checker=nullptr)
json validate(const json &, error_handler &, const json_uri &initial_uri=json_uri("#")) const
static json_validator validator(person_schema)
static json person_schema