EAN Rule

Validate European Article Numbers

117k Downloads / Month

Open Source MIT License

Explore how to validate European Article Numbers with the additional validation rules of Intervention Validation for your Laravel application.

public Intervention\Validation\Rules\Ean::__construct(array $lengths = [8, 13])

Checks for a valid European Article Number.

Parameters

lengths (optional)

Optional array of allowed lengths (8 or 13) to check only for EAN-8 or EAN-13 or both.

Example

use Illuminate\Support\Facades\Validator;
use Intervention\Validation\Rules\Ean;

$validator = Validator::make($request->all(), [
    'attribute-key' => new Ean(),
]);
use Illuminate\Support\Facades\Validator;
use Intervention\Validation\Rules\Ean;

$validator = Validator::make($request->all(), [
    'attribute-key' => new Ean([8]),
]);
Edit