parent
e14d2896ff
commit
5617eeec4e
@ -153,7 +153,7 @@ public:
|
|||||||
~json_validator();
|
~json_validator();
|
||||||
json_validator &operator=(json_validator &&);
|
json_validator &operator=(json_validator &&);
|
||||||
|
|
||||||
// insert and set thea root-schema
|
// insert and set the root-schema
|
||||||
void set_root_schema(const json &);
|
void set_root_schema(const json &);
|
||||||
|
|
||||||
// validate a json-document based on the root-schema
|
// validate a json-document based on the root-schema
|
||||||
|
|||||||
@ -171,6 +171,7 @@ public:
|
|||||||
|
|
||||||
void set_root_schema(json schema)
|
void set_root_schema(json schema)
|
||||||
{
|
{
|
||||||
|
files_.clear();
|
||||||
root_ = schema::make(schema, this, {}, {{"#"}});
|
root_ = schema::make(schema, this, {}, {{"#"}});
|
||||||
|
|
||||||
// load all files which have not yet been loaded
|
// load all files which have not yet been loaded
|
||||||
@ -225,7 +226,7 @@ public:
|
|||||||
json instance_;
|
json instance_;
|
||||||
std::string message_;
|
std::string message_;
|
||||||
|
|
||||||
void error(const json::json_pointer & ptr, const json & instance, const std::string & message) override
|
void error(const json::json_pointer &ptr, const json &instance, const std::string &message) override
|
||||||
{
|
{
|
||||||
if (*this)
|
if (*this)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -21,8 +21,12 @@ endforeach()
|
|||||||
|
|
||||||
add_executable(uri uri.cpp)
|
add_executable(uri uri.cpp)
|
||||||
target_link_libraries(uri json-schema-validator)
|
target_link_libraries(uri json-schema-validator)
|
||||||
|
add_test(NAME uri COMMAND uri)
|
||||||
|
|
||||||
add_executable(errors errors.cpp)
|
add_executable(errors errors.cpp)
|
||||||
target_link_libraries(errors json-schema-validator)
|
target_link_libraries(errors json-schema-validator)
|
||||||
|
add_test(NAME errors COMMAND errors)
|
||||||
|
|
||||||
add_test(NAME uri COMMAND uri)
|
add_executable(issue-70 issue-70.cpp)
|
||||||
|
target_link_libraries(issue-70 json-schema-validator)
|
||||||
|
add_test(NAME issue-70 COMMAND issue-70)
|
||||||
|
|||||||
44
test/issue-70.cpp
Normal file
44
test/issue-70.cpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#include <json-schema.hpp>
|
||||||
|
|
||||||
|
using nlohmann::json;
|
||||||
|
using nlohmann::json_schema::json_validator;
|
||||||
|
|
||||||
|
static const json person_schema = R"(
|
||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
|
"title": "A person",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"description": "Name",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"age": {
|
||||||
|
"description": "Age of the person",
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 2,
|
||||||
|
"maximum": 200
|
||||||
|
},
|
||||||
|
"phones": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"name",
|
||||||
|
"age"
|
||||||
|
],
|
||||||
|
"additionalProperties": false,
|
||||||
|
"type": "object"
|
||||||
|
})"_json;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
json_validator validator;
|
||||||
|
|
||||||
|
validator.set_root_schema(person_schema);
|
||||||
|
validator.set_root_schema(person_schema);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user