ex_gtin v0.3.0 ExGtin View Source

Documentation for ExGtin. This library provides functionality for validating GTIN compliant codes.

Link to this section Summary

Functions

Check for valid GTIN-8, GTIN-12, GTIN-13, GTIN-14, GSIN, SSCC codes

Generates valid GTIN-8, GTIN-12, GTIN-13, GTIN-14, GSIN, SSCC codes

Find the GS1 prefix country for a GTIN number

Link to this section Functions

Link to this function check_gtin(number) View Source
check_gtin(String.t | [number]) :: {atom, String.t}

Check for valid GTIN-8, GTIN-12, GTIN-13, GTIN-14, GSIN, SSCC codes

Returns {:ok} or {:error}

Examples

iex> ExGtin.check_gtin("6291041500213")
{:ok, "GTIN-13"}

iex> ExGtin.check_gtin("6291041500214")
{:error, "Invalid Code"}
Link to this function generate_gtin(number) View Source
generate_gtin(String.t | [number]) ::
  number |
  {atom, String.t}

Generates valid GTIN-8, GTIN-12, GTIN-13, GTIN-14, GSIN, SSCC codes

Returns code with check digit

Examples

iex> ExGtin.generate_gtin("629104150021")
"6291041500213"

iex> ExGtin.generate_gtin("62921")
{:error, "Invalid GTIN Code Length"}
Link to this function gs1_prefix_country(number) View Source
gs1_prefix_country(String.t | [number]) :: {atom, String.t}

Find the GS1 prefix country for a GTIN number

Returns {atom, String.t()}

Examples

iex> ExGtin.gs1_prefix_country("53523235")
{:ok, "GS1 Malta"}

iex> ExGtin.gs1_prefix_country("6291041500214")
{:ok, "GS1 Emirates"}

iex> ExGtin.gs1_prefix_country("9541041500214")
{:error, "No GS1 prefix found"}