@w0s/isbn-verify
v3.0.1
Published
Verify ISBN string format and check digit
Downloads
20
Readme
Verify ISBN string format and check digit
Examples
import IsbnVerify from '@w0s/isbn-verify';
const isbnVerify1 = new IsbnVerify('978-4-06-519981-0'); // ISBN with correct format but wrong check digit
isbnVerify1.isValid(); // false
isbnVerify1.isIsbn10(); // false
isbnVerify1.isIsbn10({ check_digit: true }); // false
isbnVerify1.isIsbn13(); // true
isbnVerify1.isIsbn13({ check_digit: true }); // false
isbnVerify1.verify(); // true
isbnVerify1.verify({ check_digit: true }); // false
const isbnVerify2 = new IsbnVerify('9784065199817');
isbnVerify2.isValid(); // true
const isbnVerify3 = new IsbnVerify('9784065199817', { strict: true });
isbnVerify3.isValid(); // false
Constructor
new IsbnVerify(isbn: string, options?: Option)
Parameters
Option
interface Option {
strict?: boolean; // If `true`, syntax without hyphens is an error. If not specified, it defaults to `false`
}
Methods
Option
interface VerifyOption {
check_digit?: boolean; // Verify format including check digit
}