Class BarcodeExtensions
- Namespace
- HeroKit.Barcodes
- Assembly
- HeroKit.dll
Validation helpers for GS1 product barcodes.
public static class BarcodeExtensions
- Inheritance
-
BarcodeExtensions
- Inherited Members
Methods
IsValidGtin(string?)
Checks whether a string is a valid GTIN: an EAN-8, UPC-A (12), EAN-13 or GTIN-14 barcode number with a correct GS1 check digit.
public static bool IsValidGtin(this string? value)
Parameters
valuestringThe barcode number, digits only.
Returns
- bool
True if the value has 8, 12, 13 or 14 digits and the check digit is correct; otherwise false.
Examples
"8691234567890".IsValidGtin(); // true
"8691234567891".IsValidGtin(); // false
Remarks
The first digits of an EAN-13 are the GS1 prefix of the issuing organization, not the country of origin. GS1 Türkiye uses 868 and 869.