ISBN

A library to work with ISBN written in Elixir.

Hex pm Elixir CI Coverage Status

The International Standard Book Number (ISBN) is a numeric commercial book identifier which is intended to be unique. Publishers purchase ISBNs from an affiliate of the International ISBN Agency.

An ISBN is assigned to each separate edition and variation (except reprintings) of a publication. For example, an e-book, a paperback and a hardcover edition of the same book will each have a different ISBN. The ISBN is ten digits long if assigned before 2007, and thirteen digits long if assigned on or after 1 January 2007. The method of assigning an ISBN is nation-specific and varies between countries, often depending on how large the publishing industry is within a country. Reference here

This library provides a validation that checks if the ISBN is valid and a formatter. The ISBN has check digit algorithm, you can check the details here.

Docs

The docs can be found at https://hexdocs.pm/isbnex.

Installation

If available in Hex, the package can be installed by adding isbnex to your list of dependencies in mix.exs:

def deps do
  [
    {:isbnex, "~> 0.1.0"}
  ]
end

Quick Start

You can verify if a ISBN is valid by calling the function ISBN.valid?/1:

iex> ISBN.valid?("9971502100")
true

iex> ISBN.valid?("99-9215-810-7")
true

iex> ISBN.valid?("978-0-306-40615-7")
true

iex> ISBN.valid?("978 0 306 40615 7")
true

iex> ISBN.valid?("0-9752298-0-X")
true

iex> ISBN.valid?("978-0-306-40615-6")
false

The ISBN.format/1 returns ISBN wrapped.

iex> ISBN.format("9780306406157")
"978-03-0640-615-7"

iex> ISBN.format("9992158107")
"99-9215-810-7"

iex> ISBN.format("111111")
nil