[][src]Function gtin_validate::gtin12::check

pub fn check(code: &str) -> bool

Check that a UPC-A code is valid by confirming that it is made of exactly 12 digits and that the check-digit is correct.

Examples

use gtin_validate::gtin12;

assert_eq!(gtin12::check("897854613315"), true);  // Valid GTIN-12
assert_eq!(gtin12::check("89785461331"), false);  // Too short
assert_eq!(gtin12::check("897854613318"), false); // Bad check digit