2017 © Pedro Peláez
 

library gtin

GTIN / EAN / UPC Validation for Laravel

image

mvdnbrk/gtin

GTIN / EAN / UPC Validation for Laravel

  • Tuesday, June 5, 2018
  • by mvdnbrk
  • Repository
  • 1 Watchers
  • 2 Stars
  • 173 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 220 % Grown

The README.md

GTIN / EAN / UPC Validation for Laravel

PHP version ![Latest Version on Packagist][ico-version] Software License [![Tests][ico-tests]][link-tests] ![Code style][ico-code-style] Total Downloads, (*1)

Extension for the Laravel validation class., (*2)

Installation

You can install the package via composer:, (*3)

$ composer require mvdnbrk/gtin

Usage

Now you can use the gtin validation to validate a GTIN-8, GTIN-12, GTIN-13 or GTIN-14:, (*4)

$this->validate($request, [
    'somefield' => 'gtin',
]);

Specifying a custom error message

You may publish the language files with the following artisan command:, (*5)

php artisan vendor:publish --tag=gtin-lang

Now you can customize the error message in resources/lang/vendor/gtin/{loale}/validation.php., (*6)

Another option is to define the error message by adding your message to the custom array in the resources/lang/{locale}/validation.php language file., (*7)

'custom' => [
    'somefield' => [
        'gtin' => 'Please enter a valid GTIN!',
    ],
],

Or with a JSON file stored in resources/lang/{locale}.json, (*8)

{
    "validation.custom.somefield.gtin": "Please enter a valid GTIN!"
}

Or you may pass custom messages as the third argument to the Validator::make method as described in the Laravel documentation., (*9)

Helper function

This package exposes a is_gtin() helper function to quickly validate a GTIN.
It will return a boolean whether the given value is a valid GTIN or not:, (*10)

is_gtin('1300000000000')    // returns true
is_gtin('1234567891234')    // returns false

Migrations

This package contains a helper method to create a GTIN column in your database table:, (*11)

Schema::table('products', function (Blueprint $table) {
    $table->gtin();
});

If you would like to customize the column name and/or length you may pass these as parameters:, (*12)

$table->gtin('ean13', 13);

To drop the column you may use the dropGtin method:, (*13)

Schema::table('products', function (Blueprint $table) {
    $table->dropGtin();

    // $table->dropGtin('ean13');
});

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details., (*14)

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities., (*15)

Credits

License

The MIT License (MIT). Please see License File for more information., (*16)

The Versions

05/06 2018

dev-master

9999999-dev https://github.com/mvdnbrk/gtin

GTIN / EAN / UPC Validation for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validator validation ean gs1 upc gtin

05/06 2018

v2.0.2

2.0.2.0 https://github.com/mvdnbrk/gtin

GTIN / EAN / UPC Validation for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validator validation ean gs1 upc gtin

05/06 2018

v2.0.1

2.0.1.0 https://github.com/mvdnbrk/gtin

GTIN / EAN / UPC Validation for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validator validation ean gs1 upc gtin

07/11 2017

v2.0.0

2.0.0.0 https://github.com/mvdnbrk/gtin

GTIN Validation

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validator validation ean gs1 gtin

31/08 2017

1.0.6

1.0.6.0 https://github.com/heyhoo/gtin

GTIN Validation

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validator validation ean gs1 gtin

25/05 2017

1.0.5

1.0.5.0 https://github.com/heyhoo/gtin

GTIN Validation

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validator validation ean gs1 gtin

24/05 2017

1.0.4

1.0.4.0 https://github.com/heyhoo/gtin

GTIN Validation

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validator validation ean gs1 gtin

22/05 2017

1.0.3

1.0.3.0 https://github.com/heyhoo/gtin

GTIN Validation

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validator validation ean gs1 gtin

21/05 2017

1.0.1

1.0.1.0 https://github.com/heyhoo/gtin

GTIN Validation

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validator validation ean gs1 gtin

21/05 2017

1.0.0

1.0.0.0 https://github.com/heyhoo/gtin

GTIN Validation

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validator validation ean gs1 gtin