ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - kickinespresso/ex_gtin: Elixir GTIN & UPC Generation and Validation Library
Elixir GTIN & UPC Generation and Validation Library - kickinespresso/ex_gtin
Visit Site

GitHub - kickinespresso/ex_gtin: Elixir GTIN & UPC Generation and Validation Library

GitHub - kickinespresso/ex_gtin: Elixir GTIN & UPC Generation and Validation Library

ExGtin

CI Status contributions welcome Hex.pm Packagist

A GTIN (Global Trade Item Number) & UPC (Universal Price Code) Generation and Validation Library in Elixir under the GS1 specification.

  • GTIN-8 (EAN/UCC-8): this is an 8-digit number used predominately outside of North America
  • GTIN-12 (UPC-A): this is a 12-digit number used primarily in North America
  • GTIN-13 (EAN/UCC-13): this is a 13-digit number used predominately outside of North America - Global Location Number (GLN)
  • GTIN-14 (EAN/UCC-14 or ITF-14): this is a 14-digit number used to identify trade items at various packaging levels

Features

  • Supports GTIN-8, GTIN-12 (UPC-12), GTIN-13 (GLN), GTIN-14
  • Generate GTIN
  • Check GTIN validity
  • Lookup GS1 country prefix
  • Convert (normalize) GTIN-13 to GTIN-14

Features to Come:

  • Global Shipment Identification Number (GSIN)
  • Serial Shipping Container Code (SSCC)

Installation

WARNING 1.0.1 contains breaking changes from 1.0.0 (I know this is a patch release but the breaking changes related to the deprecation of check_gtin and generate_gtin were noted in the changelog and docs over a year ago) WARNING 1.0.0 contains breaking changes from 0.4.0

Add :ex_gtin as a dependency to your project's mix.exs:

def deps do
  [{:ex_gtin, "~> 1.1.0"}]
end

and run mix deps.get to install the :ex_gtin dependency

mix deps.get

Usage

  • Check GTIN codes
iex> ExGtin.validate("6291041500213")
{:ok, "GTIN-13"}

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

iex> ExGtin.validate!("6291041500213")
"GTIN-13"

Pass GTIN numbers in as a String, Number or an Array

iex> number = [6, 2, 9, 1, 0, 4, 1, 5, 0, 0, 2, 1,3]
iex> ExGtin.validate(number)
{:ok, "GTIN-13"}

iex> number = 6_291_041_500_213
iex> ExGtin.validate(number)
{:ok, "GTIN-13"}
  • Generate GTIN codes
iex> ExGtin.generate("629104150021")
{:ok, "6291041500213"}

iex> ExGtin.generate!("629104150021")
"6291041500213"
  • Lookup GS1 Prefix
iex> ExGtin.Validation.find_gs1_prefix_country("53523235")
{:ok, "GS1 Malta"}
  • Convert GTIN-13 to GTIN 14
iex> ExGtin.normalize("6291041500213")
{:ok, "06291041500213"}

Using Strings, Arrays or Numbers

  • String
iex> ExGtin.validate("6291041500213")
{:ok, "GTIN-13"}
  • Array of Integers
iex> ExGtin.validate([6, 2, 9, 1, 0, 4, 1, 5, 0, 0, 2, 1, 3])
{:ok, "GTIN-13"}
  • Integer
iex> ExGtin.validate(6291041500213)
{:ok, "GTIN-13"}

Integers with leading zeros may not process properly

Reference

Documentation can be found at https://hexdocs.pm/ex_gtin on HexDocs.

Tests

Run tests with

mix test

Run test coverage

MIX_ENV=test mix coveralls

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

When making pull requests, please be sure to update the CHANGELOG.md with the corresponding changes. Please make sure that all tests pass, add tests for new functionality and that the static analysis checker credo is run. Use mix pull_request_checkout.task to ensure that everything checks out.

Run static code analysis

mix credo

Generate Documentation

mix docs

Run the gambit of tests, static analysis and coverage

mix pull_request_checkout.task

Sponsors

This project is sponsored by KickinEspresso

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Code of Conduct

Please refer to the Code of Conduct for details

Security

Please refer to the Security for details

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Publish & Releasing

mix hex.publish

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory