Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/solar05/exisbn
ISBN utility library for Elixir.
https://github.com/solar05/exisbn
elixir isbn isbn-10 isbn-13
Last synced: about 2 months ago
JSON representation
ISBN utility library for Elixir.
- Host: GitHub
- URL: https://github.com/solar05/exisbn
- Owner: solar05
- License: mit
- Created: 2022-12-12T22:52:57.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-07T22:22:10.000Z (7 months ago)
- Last Synced: 2024-07-07T02:49:56.902Z (3 months ago)
- Topics: elixir, isbn, isbn-10, isbn-13
- Language: Elixir
- Homepage: https://hexdocs.pm/exisbn/Exisbn.html
- Size: 42 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-elixir - exisbn - ISBN validation and formatting library. (Miscellaneous)
README
[![CI](https://github.com/solar05/exisbn/actions/workflows/elixir.yml/badge.svg)](https://github.com/solar05/exisbn/actions/workflows/elixir.yml)
![Hex.pm](https://img.shields.io/hexpm/v/exisbn)
![Hex.pm](https://img.shields.io/hexpm/l/exisbn)
# ExisbnISBN utility library for Elixir.
## Installation
The package [available in Hex](https://hex.pm/packages/exisbn) and can be installed
by adding `exisbn` to your list of dependencies in `mix.exs`:```elixir
def deps do
[
{:exisbn, "~> 2.0"}
]
end
```Documentation with examples can be found at [HexDocs.](https://hexdocs.pm/exisbn/Exisbn.html)
### Usage
Full list of examples presented at [documentation page.](https://hexdocs.pm/exisbn/Exisbn.html)
Hyphens:
```elixir
Exisbn.hyphenate("9788535902778")
{:ok, "978-85-359-0277-8"}Exisbn.hyphenate("0306406152")
{:ok, "0-306-40615-2"}Exisbn.hyphenate("str")
{:error, :invalid_isbn}
```Validations:
```elixir
Exisbn.valid?("978-5-12345-678-1")
trueExisbn.valid?("978-5-12345-678")
falseExisbn.valid?("85-359-0277-5")
trueExisbn.valid?("85-359-0277")
falseExisbn.correct_hyphens?("978-85-359-0277-8")
true
Exisbn.correct_hyphens?("97-8853590277-8")
false
Exisbn.correct_hyphens?("0-306-40615-2")
true
Exisbn.correct_hyphens?("03-064-06152")
falseExisbn.checkdigit_correct?("85-359-0277-5")
true
Exisbn.checkdigit_correct?("978-5-12345-678-1")
true
Exisbn.checkdigit_correct?("978-5-12345-678")
false
```Additional info:
```elixir
Exisbn.publisher_zone("9788535902778")
{:ok, "Brazil"}
Exisbn.publisher_zone("2-1234-5680-2")
{:ok, "French language"}
Exisbn.publisher_zone("str")
{:error, :invalid_isbn}Exisbn.fetch_registrant_element("9788535902778")
{:ok, "359"}
Exisbn.fetch_registrant_element("978-1-86197-876-9")
{:ok, "86197"}Exisbn.fetch_publication_element("978-1-86197-876-9")
{:ok, "876"}
Exisbn.fetch_publication_element("9789529351787")
{:ok, "5178"}Exisbn.fetch_prefix("9788535902778")
{:ok, "978-85"}
Exisbn.fetch_prefix("2-1234-5680-2")
{:ok, "978-2"}Exisbn.fetch_checkdigit("9788535902778")
{:ok, 8}
Exisbn.fetch_checkdigit("2-1234-5680-2")
{:ok, 2}
```