isbn-verify
v1.0.1
Published
Minimal ISBN-10 and ISBN-13 validator
Downloads
54
Readme
Minimal ISBN validator
Verify an ISBN in format of ISBN-10 and ISBN-13.
Instalation
yarn add isbn-verify
or
npm install isbn-verify --save
Quick start
Simply import 'isbn-verify' and call static method called ISBN.Verify. Then pass the ISBN you want to check as an argument to verify.
ISBN should be in string format, but numbers will also work (number will be converted into string with global method Number.prototype.toString).
Then verify method will return true or false.
Example:
const ISBN = require('isbn-verify');
ISBN.Verify( '048665088X' ); //true - ISBN-13
ISBN.Verify( '9788371815102' ); //true - ISBN-13
ISBN.Verify( '048665088A' ); //false - invalid letter 'A'
ISBN.Verify( '03064061521' ); //false - to many digits
Optional prefixes in ISBN nubers
ISBN number is checked with regular expression, which allowed optional prefixes. Example prefixes which will be removed after validate control digit in ISBN:
ISBN number
ISBN: number
ISBN-10 number
ISBN-13 number
ISBN-10: number
ISBN-13: number
and with small letters:
isbn number
isbn: number
isbn-10 number
isbn-13 number
isbn-10: number
isbn-13: number
After 'ISBN' have to been one space, char ':' or symbol of ISBN type (10 or 13). Always before whole number have to been one space! For example the following ISBN numbers will validated as incorrect:
ISBNnumber
ISBN:number
ISBN-10number
ISBN-13number
ISBN-10:number
ISBN-13:number
Char 'X' or 'x' as control digit
In INSB-13 is allowed char 'X' or 'x' as last digit (control digit), when checksum for number is equal 10. In ISBN-13 number char 'X' and 'x' is not allowed.
Note: This libarary has created by using https://github.com/drogimex/isbn-validate library