Validate Bill Information String

import ch.codeblock.qrinvoice.model.validation.BillInformationValidator;
import ch.codeblock.qrinvoice.model.validation.ValidationResult;

// ..
// validate
final ValidationResult validationResult = BillInformationValidator.create().validate("//S1/32/7.7:100;8:10");
if(validationResult.hasErrors()) {
    // handle validation errors
}

Validate Bill Information Object

import ch.codeblock.qrinvoice.model.billinformation.BillInformation;

import ch.codeblock.qrinvoice.model.validation.BillInformationValidator;
import ch.codeblock.qrinvoice.model.validation.ValidationResult;

// ..
final BillInformation billInformation = ... ; // SwicoS1v12 is a subtype of BillInformation
final ValidationResult validationResult = BillInformationValidator.create().validate(billInformation);
if(validationResult.hasErrors()) {
    // handle validation errors
}

Validate Bill Information Object with QR Invoice

If you pass a QrInvoice object along with the BillInformation, cross validations occur (such as VatDetails are checked against amount of QrInvoice)

import ch.codeblock.qrinvoice.model.QrInvoice;
import ch.codeblock.qrinvoice.model.billinformation.BillInformation;

import ch.codeblock.qrinvoice.model.validation.BillInformationValidator;
import ch.codeblock.qrinvoice.model.validation.ValidationResult;

// ..

final QrInvoice qrInvoice = ... ;
final BillInformation billInformation = ... ; // SwicoS1v12 is a subtype of BillInformation

// validate
final ValidationResult validationResult = BillInformationValidator.create().validate(qrInvoice, billInformation);
if(validationResult.hasErrors()) {
    // handle validation errors
}

Validate Bill Information of Unknown Type

import ch.codeblock.qrinvoice.model.validation.BillInformationValidator;
import ch.codeblock.qrinvoice.model.validation.ValidationResult;

// ..

// This will result in a ParseException as Type / Prefix of this bill information is unkown - however the bill information may be valid (open by Swiss Implementation Guidelines QR-bill)
final ValidationResult validationResult = BillInformationValidator.create().validate("//XY");