Fix README so the code actually throws, when json is invalid

This commit is contained in:
Ayaz Salikhov 2020-10-01 17:31:04 +03:00 committed by GitHub
parent 89e37cbf42
commit 45b0f83b5a
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.