Merge pull request #99 from mathbunnyru/patch-1

Fix README so the code actually throws, when json is invalid
This commit is contained in:
Tristan Penman 2020-10-02 08:37:07 +10:00 committed by GitHub
commit 6cda9227cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,7 +57,7 @@ Validate a document:
Validator validator;
RapidJsonAdapter myTargetAdapter(myTargetDoc);
if (!validator.validate(mySchema, myTargetAdapter, NULL)) {
std::runtime_error("Validation failed.");
throw std::runtime_error("Validation failed.");
}
Note that Valijson's `SchemaParser` and `Validator` classes expect you to pass in a `RapidJsonAdapter` rather than a `rapidjson::Document`. This is due to the fact that `SchemaParser` and `Validator` are template classes that can be used with any of the JSON parsers supported by Valijson.