ExGtin v0.4.0 ExGtin View Source

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

Link to this section Summary

Functions

check_gtin(number) deprecated

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

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

Find the GS1 prefix country for a GTIN number

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

Link to this section Functions

Link to this function

check_gtin(number)

View Source
check_gtin(String.t() | [number()]) :: {atom(), String.t()}
This function is deprecated. Use validate/1 instead. Will be removed in version 0.5.0.

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(number)

View Source
generate(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("629104150021")
"6291041500213"

iex> ExGtin.generate("62921")
{:error, "Invalid GTIN Code Length"}
Link to this function

generate_gtin(number)

View Source
generate_gtin(String.t() | [number()]) :: number() | {atom(), String.t()}
This function is deprecated. Use generate/1 instead. Will be removed in version 0.5.0.

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"}
Link to this function

validate(number)

View Source
validate(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.validate("6291041500213")
{:ok, "GTIN-13"}

iex> ExGtin.validate("6291041500214")
{:error, "Invalid Code"}