Here you learn how to manually validate a QR Invoice object and how to get details out of the validation result.

#include <string>
#include <iostream>
#include <vector>

#include <qrinvoice/model/qr_invoice.hpp>
#include <qrinvoice/model/validation.hpp>

// ...

const qrinvoice::model::qr_invoice qr_invoice = // create using qr_invoice::builder;

// now set some invalid data

// creditor must be set, this will result in a validation error
// set an unsupported QR Type

const qrinvoice::model::validation::validation_result vr = qrinvoice::model::validation::validate(qr_invoice);

if(vr.has_errors()) {
    const std::string &validation_error_summary = vr.get_validation_error_summary();

    std::cout << validation_error_summary << std::endl;

    // access each validation error on its own
    const std::vector<qrinvoice::model::validation::validation_result::validation_error> &errors = vr.get_errors();
    // ...

The snippet above will print a summary of the validation errors.

QrInvoice has validation errors:
1. 'header.qrType' has invalid value 'foo'
    => Fixed length: three-digit, alphanumeric
    => Unambiguous indicator for the Swiss QR Code. Fixed value “SPC” (Swiss Payments Code)
2. '' has invalid value ''
    => First name (optional, if available) + last name or company name
    => Maximum 70 characters permitted

Of course, you can get the details for each validation error

// access each validation_error on its own
const vector<qrinvoice::model::validation::validation_result::validation_error> &vector = vr.get_errors();
for(const qrinvoice::model::validation::validation_result::validation_error &error : vector) {
    std::cout << error.get_data_path() << std::endl;
    std::cout << error.get_value() << std::endl;
    for(const std::string &error_msg_key : error.get_error_msg_keys()) {
        std::cout << error_msg_key << std::endl;
// ...