Added expected values to enum and const error messages
This commit is contained in:
parent
813eb6312b
commit
66efaf9e97
@ -429,8 +429,7 @@ enum logical_combination_types {
|
|||||||
class logical_combination_error_handler : public error_handler
|
class logical_combination_error_handler : public error_handler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct error_entry
|
struct error_entry {
|
||||||
{
|
|
||||||
json::json_pointer ptr_;
|
json::json_pointer ptr_;
|
||||||
json instance_;
|
json instance_;
|
||||||
std::string message_;
|
std::string message_;
|
||||||
@ -440,12 +439,12 @@ public:
|
|||||||
|
|
||||||
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
|
||||||
{
|
{
|
||||||
error_entry_list_.push_back(error_entry{ ptr, instance, message });
|
error_entry_list_.push_back(error_entry{ptr, instance, message});
|
||||||
}
|
}
|
||||||
|
|
||||||
void propagate(error_handler& e, const std::string& prefix) const
|
void propagate(error_handler &e, const std::string &prefix) const
|
||||||
{
|
{
|
||||||
for (const error_entry& entry : error_entry_list_)
|
for (const error_entry &entry : error_entry_list_)
|
||||||
e.error(entry.ptr_, entry.instance_, prefix + entry.message_);
|
e.error(entry.ptr_, entry.instance_, prefix + entry.message_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,7 +462,7 @@ class logical_combination : public schema
|
|||||||
logical_combination_error_handler error_summary;
|
logical_combination_error_handler error_summary;
|
||||||
|
|
||||||
for (std::size_t index = 0; index < subschemata_.size(); ++index) {
|
for (std::size_t index = 0; index < subschemata_.size(); ++index) {
|
||||||
const std::shared_ptr<schema>& s = subschemata_[index];
|
const std::shared_ptr<schema> &s = subschemata_[index];
|
||||||
logical_combination_error_handler esub;
|
logical_combination_error_handler esub;
|
||||||
auto oldPatchSize = patch.get_json().size();
|
auto oldPatchSize = patch.get_json().size();
|
||||||
s->validate(ptr, instance, patch, esub);
|
s->validate(ptr, instance, patch, esub);
|
||||||
@ -513,8 +512,7 @@ const std::string logical_combination<oneOf>::key = "oneOf";
|
|||||||
template <>
|
template <>
|
||||||
bool logical_combination<allOf>::is_validate_complete(const json &, const json::json_pointer &, error_handler &e, const logical_combination_error_handler &esub, size_t, size_t current_schema_index)
|
bool logical_combination<allOf>::is_validate_complete(const json &, const json::json_pointer &, error_handler &e, const logical_combination_error_handler &esub, size_t, size_t current_schema_index)
|
||||||
{
|
{
|
||||||
if (esub)
|
if (esub) {
|
||||||
{
|
|
||||||
e.error(esub.error_entry_list_.front().ptr_, esub.error_entry_list_.front().instance_, "at least one subschema has failed, but all of them are required to validate - " + esub.error_entry_list_.front().message_);
|
e.error(esub.error_entry_list_.front().ptr_, esub.error_entry_list_.front().instance_, "at least one subschema has failed, but all of them are required to validate - " + esub.error_entry_list_.front().message_);
|
||||||
esub.propagate(e, "[combination: allOf / case#" + std::to_string(current_schema_index) + "] ");
|
esub.propagate(e, "[combination: allOf / case#" + std::to_string(current_schema_index) + "] ");
|
||||||
}
|
}
|
||||||
@ -568,12 +566,12 @@ class type_schema : public schema
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!seen_in_enum)
|
if (!seen_in_enum)
|
||||||
e.error(ptr, instance, "instance not found in required enum");
|
e.error(ptr, instance, "instance not found in required enum " + enum_.second.dump());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const_.first &&
|
if (const_.first &&
|
||||||
const_.second != instance)
|
const_.second != instance)
|
||||||
e.error(ptr, instance, "instance not const");
|
e.error(ptr, instance, "instance not const value '" + const_.second.dump() + "'");
|
||||||
|
|
||||||
for (auto l : logic_)
|
for (auto l : logic_)
|
||||||
l->validate(ptr, instance, patch, e);
|
l->validate(ptr, instance, patch, e);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user