[][src]Function gtin_validate::gtin14::check

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

Check that a GTIN-14 code is valid by confirming that it is exactly 14 digits in length and that the check-digit is correct.

Examples

use gtin_validate::gtin14;

assert_eq!(gtin14::check("14567815983469"), true);  // Valid GTIN-14
assert_eq!(gtin14::check("1456781598346"), false);  // too short
assert_eq!(gtin14::check("14567815983468"), false); // Bad check digit