---
application: "Intervention Validation"
version: "Version 4"
status: "stable"
---

# EAN Rule

## Validate European Article Numbers

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](https://en.wikipedia.org/wiki/International_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

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

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

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

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

---

## Become a Sponsor

### Intervention Validation needs your help to keep the project going

Intervention Validation is non-commercial, open source licensed and completely free to use. The considerable
effort required to maintain and develop the software is only possible with the financial support
of sponsors. There are two ways in which you can support this project.

- Support via [GitHub Sponsors](https://github.com/sponsors/Intervention)
- Support via [Ko-Fi](https://ko-fi.com/interventionphp)