SwissQrBill.Validation (swiss_qr_bill v0.1.2)

Copy Markdown View Source

Validation logic for Swiss QR bill data.

Summary

Functions

Validates that a string contains only characters allowed in Swiss QR codes.

Validates a creditor reference (ISO 11649 / SCOR format). Must start with RF, followed by 2 check digits, then 1-21 alphanumeric chars. Check digits are validated using mod-97-10.

Validates the mod-10 recursive check digit of a QR reference. Uses the standard Swiss modulo-10 table.

Validates a complete QR bill. Returns {:ok, bill} or {:error, errors}.

Functions

valid_characters?(string)

@spec valid_characters?(String.t()) :: boolean()

Validates that a string contains only characters allowed in Swiss QR codes.

valid_creditor_reference?(reference)

@spec valid_creditor_reference?(String.t()) :: boolean()

Validates a creditor reference (ISO 11649 / SCOR format). Must start with RF, followed by 2 check digits, then 1-21 alphanumeric chars. Check digits are validated using mod-97-10.

valid_mod10_check_digit?(reference)

@spec valid_mod10_check_digit?(String.t()) :: boolean()

Validates the mod-10 recursive check digit of a QR reference. Uses the standard Swiss modulo-10 table.

validate(bill)

Validates a complete QR bill. Returns {:ok, bill} or {:error, errors}.