MyNixOS website logo
Description

ISBN Validation and Manipulation.

isbn: ISBN Validation and Manipulation

Build Status Hackage Stackage LTS Stackage Nightly Apache-2.0

All books published by major publishers since 1970 have an International Standard Book Number (ISBN) associated with them. Prior to 2007, all ISBNs issued were ten digit ISBN-10 format. Since 2007, new ISBNs have been issued in the thirteen digit ISBN-13 format. See the ISBN Wikipedia article for more information.

Overview

This library provides data types and functions both validating and working with ISBNs. For general use, only importing the Data.ISBN module is required, as it reexports all functionality for validating and converting between ISBN-10 and ISBN-13 values. The specific implementations for validation are located in the Data.ISBN.ISBN10 and Data.ISBN.ISBN13 modules, respectively.

Usage Example: Validating an ISBN and printing the error

import Data.ISBN (ISBN, validateISBN, renderISBNValidationError)

validateUserSuppliedISBN :: Text -> Either Text ISBN
validateUserSuppliedISBN userIsbnInput =
    either (Left . renderISBNValidationError) Right (validateISBN userIsbnInput)


someValidISBN10 =
    validateUserSuppliedISBN "0345816021"    -- Right (ISBN10 "0345816021")

someValidISBN13 =
    validateUserSuppliedISBN "9780807014295" -- Right (ISBN13 "9780807014295")

tooShortISBN =
    validateUserSuppliedISBN "0-345-816"     -- Left "An ISBN must be 10 or 13 characters, not counting hyphens"

invalidISBN10 =
    validateUserSuppliedISBN "0-345-81602-3" -- Left "The supplied ISBN-10 is not valid"

Development

This library is developed using a Nix shell. The environment is specified in shell.nix. You can enter the environment with nix installed via nix-shell. The nix-shell will install sandboxed copies of cabal-install, ghcid, entr, and gnumake, which are the utilities necessary to build the project, run the tests, and create a local copy of the documentation.

Entering the development environment and runnning tests

$ cd <path-to-repo>
$ nix-shell                       # assumes `nix` is installed
(nix-shell) $ make help           # show all of the make targets
(nix-shell) $ make tests-watch    # build the library and run the tests in `ghcid`
(nix-shell) $ make docs           # build a local copy of the haddock documentation
Metadata

Version

1.1.0.5

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows