GTIN Rule
Validate a Global Trade Item Number
169k Downloads / Month
Open Source MIT License
169k Downloads / Month
Open Source MIT License
Validate Global Trade Item Numbers (GTIN) in Laravel with Intervention Validation. Product ID checks.
public Intervention\Validation\Rules\Gtin::__construct(array $lengths = [8, 12, 13, 14])
Checks for a valid Global Trade Item Number.
Optional array of allowed lengths to check only for certain types (GTIN-8, GTIN-12, GTIN-13 or GTIN-14).
use Illuminate\Support\Facades\Validator; use Intervention\Validation\Rules\Gtin; // validate GTIN $validator = Validator::make($request->all(), [ 'attribute-key' => new Gtin(), ]);
use Illuminate\Support\Facades\Validator; use Intervention\Validation\Rules\Gtin; // validate GTIN-8 or GTIN-12 $validator = Validator::make($request->all(), [ 'attribute-key' => new Gtin([8, 12]), ]);