Library
Module
Module type
Parameter
Class
Class type
Module encapsulating ISBNs. It makes sure that any given ISBN is correct, taking advantage of the check digit present in every ISBN. It supports both 10 and 13-digit ISBNs.
The PGOCAML-compatible type used for (de)serialising values of type t
val of_string : string -> [> `ISBN10 | `ISBN13 ] t
Converts a string into an ISBN, represented by type t
. Raises Invalid_arg
if the string cannot be converted into a valid ISBN. Both 10 and 13-digit ISBNs are accepted. Moreover, the string may contain dashes, which are automatically removed if present.
val to_string : [< `ISBN10 | `ISBN13 ] t -> string
Converts a t
(representing an ISBN) into a string.
Converts a given t
into a 10-digit ISBN. If the supplied ISBN is already a 10-digit ISBN then it's returned unchanged. If the supplied ISBN is a backwards-compatible 13-digit ISBN (it starts with "978"), then it is converted. Otherwise, the conversion is not possible and None
is returned.
Converts a given t
into a 13-digit ISBN. If the supplied ISBN is already a 13-digit ISBN then it's returned unchanged. If the supplied ISBN is a 10-digit ISBN then it's converted by prepending a "978" and recomputing the check digit.
Deserialises from a PGOCAML-compatible format. Should only be used for 10-digit ISBNs.
Deserialises from a PGOCAML-compatible format. Should only be used for 13-digit ISBNs.
Does the given string represent a valid ISBN number? Both 10 and 13-digit ISBNs are accepted. Moreover, the string may contain dashes, which are automatically removed if present.