[][src]Function bookbinder_common::validate_isbn

pub fn validate_isbn<S: AsRef<str>>(isbn: S) -> bool

Validate that a str can be interpreted as an isbn-13. A str will be valid whatever its non-digit components so long as it has at least 13 digits and the last digit is the correct checksum, for the first 12 (or first 12 after a preceding 13) This allows, for example, the validation of prefixed or hyphenated isbns:

use bookbinder_common::validate_isbn;
assert!(validate_isbn("ISBN13 978-1-4920-6766-5"));
assert!(validate_isbn("ISBN-13 9781492067665"));
assert!(validate_isbn("978-1-4920-6766-5"));
assert!(validate_isbn("9781492067665"));
assert!(validate_isbn("ISBN13 978-1-4920-6766-5 (epub)"));