View Source Exisbn (Exisbn v0.1.2)

Documentation for Exisbn.

Link to this section Summary

Functions

Takes an ISBN (10 or 13) and checks its validity by its check digit

Takes an ISBN and returns its checkdigit.

Takes an ISBN and returns its prefix.

Takes an ISBN 10 code as string, returns its check digit.

Takes an ISBN 10 and converts it to ISBN 13.

Takes an ISBN 13 code as string, returns its check digit.

Takes an ISBN 13 and converts it to ISBN 10.

Takes an ISBN and returns its publisher zone.

Takes an ISBN (10 or 13) and checks its validity by checking the checkdigit, length and characters.

Link to this section Functions

Link to this function

checkdigit_correct?(isbn)

View Source
@spec checkdigit_correct?(String.t()) :: boolean()

Takes an ISBN (10 or 13) and checks its validity by its check digit

examples

Examples

iex> Exisbn.checkdigit_correct?("85-359-0277-5")
true
iex> Exisbn.checkdigit_correct?("978-5-12345-678-1")
true
iex> Exisbn.checkdigit_correct?("978-5-12345-678")
false
@spec fetch_checkdigit(String.t()) :: String.t() | nil

Takes an ISBN and returns its checkdigit.

examples

Examples

iex> Exisbn.fetch_checkdigit("9788535902778")
8
iex> Exisbn.fetch_checkdigit("2-1234-5680-2")
2
iex> Exisbn.fetch_checkdigit("str")
nil
@spec get_prefix(String.t()) :: String.t() | nil

Takes an ISBN and returns its prefix.

examples

Examples

iex> Exisbn.get_prefix("9788535902778")
"978-85"
iex> Exisbn.get_prefix("2-1234-5680-2")
"978-2"
iex> Exisbn.get_prefix("str")
nil
@spec isbn10_checkdigit(String.t()) :: nil | <<_::8>> | integer()

Takes an ISBN 10 code as string, returns its check digit.

examples

Examples

iex> Exisbn.isbn10_checkdigit("85-359-0277")
5
iex> Exisbn.isbn10_checkdigit("5-02-013850")
9
iex> Exisbn.isbn10_checkdigit("0str")
nil
@spec isbn10_to_13(String.t()) :: String.t() | nil

Takes an ISBN 10 and converts it to ISBN 13.

examples

Examples

iex> Exisbn.isbn10_to_13("85-359-0277-5")
"9788535902778"
iex> Exisbn.valid?("9788535902778")
true
iex> Exisbn.isbn10_to_13("0306406152")
"9780306406157"
iex> Exisbn.valid?("9780306406157")
true
iex> Exisbn.isbn10_to_13("0-19-853453123")
nil
@spec isbn13_checkdigit(binary()) :: nil | integer()

Takes an ISBN 13 code as string, returns its check digit.

examples

Examples

iex> Exisbn.isbn13_checkdigit("978-5-12345-678")
1
iex> Exisbn.isbn13_checkdigit("978-0-306-40615")
7
iex> Exisbn.isbn13_checkdigit("0str")
nil
@spec isbn13_to_10(String.t()) :: String.t() | nil

Takes an ISBN 13 and converts it to ISBN 10.

examples

Examples

iex> Exisbn.isbn13_to_10("9788535902778")
"8535902775"
iex> Exisbn.valid?("8535902775")
true
iex> Exisbn.isbn13_to_10("9780306406157")
"0306406152"
iex> Exisbn.valid?("0306406152")
true
iex> Exisbn.isbn13_to_10("str")
nil
@spec publisher_zone(String.t()) :: String.t() | nil

Takes an ISBN and returns its publisher zone.

examples

Examples

iex> Exisbn.publisher_zone("9788535902778")
"Brazil"
iex> Exisbn.publisher_zone("2-1234-5680-2")
"French language"
iex> Exisbn.publisher_zone("str")
nil
@spec valid?(String.t()) :: boolean()

Takes an ISBN (10 or 13) and checks its validity by checking the checkdigit, length and characters.

examples

Examples

iex> Exisbn.valid?("978-5-12345-678-1")
true
iex> Exisbn.valid?("978-5-12345-678-1")
true
iex> Exisbn.valid?("978-5-12345-678")
false
iex> Exisbn.valid?("85-359-0277-5")
true
iex> Exisbn.valid?("85-359-0277")
false