---
application: "Intervention Validation"
version: "Version 3"
status: "eol"
---

# GTIN Rule

## Validate a Global Trade Item Number



> public Intervention\Validation\Rules\Gtin::__construct(?int $length = null)

Checks for a valid [Global Trade Item Number](https://en.wikipedia.org/wiki/Global_Trade_Item_Number).

### Parameters

#### length (optional)

Optional integer length to check only for certain types (GTIN-8, GTIN-12, GTIN-13 or GTIN-14).

### Example

```php
use Intervention\Validation\Rules\Gtin;

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

---

## 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)