imelgrat / barcode-validator Goto Github PK
View Code? Open in Web Editor NEWA PHP class for validating EAN, IMEI, ISBN, GTIN, SSCC, GSIN, UPC and other similar codes.
License: MIT License
A PHP class for validating EAN, IMEI, ISBN, GTIN, SSCC, GSIN, UPC and other similar codes.
License: MIT License
i have encountered manufacturers who are using a 2 digit suffix at the end of the 12 digit UPC bar code. the 2 digit suffix indicates a packaging of some sort. you are returning false if the length is not the expected length.
barcode-validator/src/BarcodeValidator.php
Lines 71 to 72 in 6512e3b
here is one such code: 84788101273501
upczilla does validate this code as true while your validator automatically returns false.
Commit e41cc18 contains crucial fix for check digit validation but version was not increased since then.
This means that composer install for newest version contains wrong check digit algorithm which thinks that 5050953104518 is valid Ean13 but in fact 5050953104510 is.
Hey,
your code does not work with common ISBN 13 and UPC codes. Try followings
ISBN: 9780241235645
UPC: 883929344130
Works with ISBn 10 e.g.
1870089049
Thanks
Hi, is it possible to push version 1.1.2 to packagist?
The version that composer is downloading is 1.1.1.
Thanks
autoload.php
is included correctly.\BarcodeValidator::IsValidUPCA()
, I get class \BarcodeValidator
not found.barcode-validator.php
, while usually it should be BarcodeValidator.php
for the composer's autoload to work ๐คBarcodeValidator.php
and it gets auto-loaded correctly. public static function IsValidIMEI($code = '')
{
// Remove hyphens
$code = str_replace('-', '', $code);
if (preg_match('/^[0-9]+$/', $code)) {
switch (strlen($code)) {
case 14: // No check digit. always true
return true;
break;
case 15: // IMEI number with check digit. Test check digit
return BarcodeValidator::validateLuhnCheckDigit($code, 15);
break;
case 16: // It's a IMEISV code (IMEI Software Version). No check digit
return true;
break;
default: // +
return false; // +
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.