Giter Club home page Giter Club logo

productvalidation's Introduction

ProductValidation

ProductValidator is a simply utility for Shopping cart software or custom projects to validate product codes.

Supports UPC-A, UPC-E 6, 7 and 8, EAN13 and ISBN10/ISBN13.

This software is free to use, distribute and change as you see fit according to the MIT Variant license.

Composer Ready

Available on Packagist: https://packagist.org/packages/rottingham/product-code-validation

Sample Usage

Simply import the ProductValidator.class.inc main class file if you are not utilizing auto loaders.

require '/ProductValidator.class.inc';

To use the validator, you can simply call its checkCode($code) method:

$result = ProductValidator\ProductValidator::checkCode('1560213639');

var_dump($result);

checkCode attempts to smartly detect the codes type and returns and array containing the code type, (UPC, EAN, ISBN) the checkDigit for the code, and the isbn pieces if the code is an ISBN.

Individual Code Validation

To validate (TRUE|FALSE) a code you already know the type of, use ProductValidator's individual check functions:

var_dump(ProductValidator\ProductValidator::checkUpc('748196000441');
var_dump(ProductValidator\ProductValidator::checkEan('9781560213635');
var_dump(ProductValidator\ProductValidator::checkIsbn('1560213635');

checkUpc, checkEan and checkIsbn return TRUE if the check digit and code validates, or FALSE if they do not.

Validators

  • UpcValidator
  • EanValidator
  • IsbnValidator

productvalidation's People

Contributors

rottingham avatar ralphstoys avatar

Watchers

Malte avatar James Cloos avatar

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.