View Source QRNBU.Types (NBU payment QR v0.3.3)

Custom domain types for NBU QR code library.

This module provides opaque types with built-in validation for domain concepts used in NBU QR code generation. Using these types instead of primitives provides:

  • Compile-time type safety
  • Validation at construction time
  • Self-documenting code
  • Protection against invalid data entering the system

Types

  • IBAN - Ukrainian IBAN (29 characters)
  • Amount - Monetary amount with 2 decimal precision
  • TaxID - Tax identification number (8-10 digits, excluding 9)
  • RecipientCode - V003 recipient identification code

Examples

iex> {:ok, iban} = QRNBU.Types.IBAN.new("UA303348510000026206114040874")
iex> QRNBU.Types.IBAN.to_string(iban)
"UA303348510000026206114040874"

iex> {:ok, amount} = QRNBU.Types.Amount.new(100.50)
iex> QRNBU.Types.Amount.to_decimal(amount)
#Decimal<100.50>

iex> QRNBU.Types.TaxID.new("123")
{:error, "Tax ID must be at least 8 characters"}