ISBN Verify
Verify ISBN string format and check digit.
Demo
Examples
import IsbnVerify from '@saekitominaga/isbn-verify';
const isbnVerify = new IsbnVerify('978-4-06-519981-0');
isbnVerify.isValid(); // false
isbnVerify.isIsbn10(); // false
isbnVerify.isIsbn13(); // true
isbnVerify.isIsbn13({ check_digit: true }); // false
isbnVerify.verifyFormat(); // true
isbnVerify.verifyCheckDigit(); // false
Constructor
new IsbnVerify(isbn: string, strict = false)
Parameters
isbn
- ISBN value to check
strict` [Optional]
- Strict mode. If `true`, syntax without hyphens is an error. If not specified, it defaults to `false`
Methods
isValid(): boolean
- Alias of `verifyCheckDigit()`
isIsbn13(options?: isOption): boolean
- Whether it is a 13-digit ISBN
isIsbn10(options?: isOption): boolean
- Whether it is a 10-digit ISBN
verifyFormat(): boolean
- Verify format (do not verify check digit)
verifyCheckDigit(): boolean
- Verify format including check digit (not necessarily applicable publication)
isIsbn13()
and isIsbn10()
method
Arguments of interface isOption {
check_digit?: boolean; // Verify format including check digit
}
* isIsbnXX({ check_digit: true })
has the same effect as isIsbnXX() && isValid()
.