Git Product home page Git Product logo

barcode-validator's People

Contributors

amirtheahmed avatar imelgrat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

barcode-validator's Issues

length should not invalidate bar code.

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.

// Check if the string length matches the code's desired length
if (strlen($code) == $length) {

here is one such code: 84788101273501

upczilla does validate this code as true while your validator automatically returns false.

Update version number

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.

Does not work for ISBN 13 and UPC codes

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

Autoload not working

The problem

  • I installed the library with composer.
  • Composer's autoload.php is included correctly.
  • When I call \BarcodeValidator::IsValidUPCA(), I get class \BarcodeValidator not found.

Possible solution

  • Upon investigation, I found that the class is written in a barcode-validator.php, while usually it should be BarcodeValidator.php for the composer's autoload to work ๐Ÿค”
  • I copied the file to BarcodeValidator.php and it gets auto-loaded correctly.

small fix

		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; // +
				}
			}
		}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.