isbn-validate

1.0.3 • Public • Published

Simple ISBN validator

NPM Version Build Status License Downloads

Validator check ISBN in format ISBN-10 and ISBN-13.

Instalation

npm install isbn-validate

Simple using

For use ISBN validator you have to import 'isbn-validate' and call static method ISBN.Validate. This method accept one argument - isbn number to validate. ISBN should be string type, but number type also is right (number will converted to string with global method Number.prototype.toString).

Method ISBN.Validate always returns boolean value TRUE or FALSE.

Example:

const ISBN = require( 'isbn-validate' );
 
ISBN.Validate( '048665088X' );    //true - ISBN-13
ISBN.Validate( '9788371815102' ); //true - ISBN-13
 
ISBN.Validate( '048665088A' );    //false - invalid letter 'A'
ISBN.Validate( '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.

Readme

Keywords

Package Sidebar

Install

npm i isbn-validate

Weekly Downloads

3

Version

1.0.3

License

MIT

Last publish

Collaborators

  • tomek-sochacki