valijson failed to return error msg when use if-else
Closed this issue · 2 comments
danielab1 commented
hey, I used the if-else statement in my schema, I see that the valijson failed to validate the schema but isn't print any error message,
this is the code I run -
Validator validator;
RapidJsonAdapter myTargetAdapter(doc);
ValidationResults results;
if (!validator.validate(mySchema, myTargetAdapter, &results)) {
std::stringstream err_oss;
ValidationResults::Error error;
int error_num = 1;
while (results.popError(error)) {
std::string context;
for (auto& val : error.context) {
context += val;
}
err_oss << "Error #" << error_num << std::endl
<< " context: " << context << std::endl
<< " desc: " << error.description << std::endl;
++error_num;
}
std::string error_string(err_oss.str());
if (!error_string.empty()) {
m_logger->error(err_oss.str());
} else {
m_logger->error("Error occurred while schema validating the following JSON: \n {} \n", json);
}
return false;
}
thanks a lot.
lightydo commented
version 0.4 seems to resolve this issue.
tristanpenman commented
Glad to hear you got this working. This was probably fixed in this commit: cbcde15
Sounds like the issue is resolved, so I'm going to close this ticket for now. Feel free to re-open it if you discover any related problems.