View Source UkraineTaxidEx.Edrpou.Parser (ukraine_tax_id v0.1.1)

Parser module for EDRPOU (Unified State Register of Ukrainian Enterprises and Organizations) codes. Handles validation and structure creation for EDRPOU codes with additional options for normalization and cleaning.

Parses an EDRPOU code string into a structured format (clean and normalize, validate and decompo). Options:

  • normalize?: When true, pads string to full EDRPOU length. Defaults to false.
  • clean?: When true, removes non-digit characters before processing. Defaults to false. Returns {:ok, %Edrpou{}} for valid codes or {:error, reason} for invalid.

Examples

    iex> UkraineTaxidEx.Edrpou.Parser.parse("00032112")
    {:ok, %UkraineTaxidEx.Edrpou{code: "00032112", check_digit: 2, check_sum: 2}}

    iex> UkraineTaxidEx.Edrpou.Parser.parse({:ok, "00032112"})
    {:ok, %UkraineTaxidEx.Edrpou{code: "00032112", check_digit: 2, check_sum: 2}}

    iex> UkraineTaxidEx.Edrpou.Parser.parse("32129", normalize?: true)
    {:ok, %UkraineTaxidEx.Edrpou{code: "00032129", check_digit: 9, check_sum: 9}}

    iex> UkraineTaxidEx.Edrpou.Parser.parse("9 30test62 78", normalize?: true, clean?: true)
    {:ok, %UkraineTaxidEx.Edrpou{code: "09306278", check_digit: 8, check_sum: 8}}

    iex> UkraineTaxidEx.Edrpou.Parser.parse("123")
    {:error, :length_too_short}

    iex> UkraineTaxidEx.Edrpou.Parser.parse("123456789")
    {:error, :length_too_long}

    iex> UkraineTaxidEx.Edrpou.Parser.parse("123", normalize?: true)
    {:error, :invalid_checksum}

Summary

Types

edrpou()

@type edrpou() :: UkraineTaxidEx.Edrpou.t()

edrpou_or_error()

@type edrpou_or_error() ::
  {:ok, UkraineTaxidEx.Edrpou.t()}
  | {:error, :length_too_short | :length_too_long | :invalid_checksum}

edrpou_string()

@type edrpou_string() :: String.t()

string_or_ok()

@type string_or_ok() :: String.t() | {:ok, String.t()}

struct_or_error()

@type struct_or_error() :: {:ok, term()} | {:error, atom()}