x-laravel / validation-tr-tax-number-extend
Turkey tax number validation extend package for Laravel.
Package info
github.com/x-laravel/validation-tr-tax-number-extend
pkg:composer/x-laravel/validation-tr-tax-number-extend
Requires
- php: ^8.2
- illuminate/contracts: ^12.0 || ^13.0
- illuminate/support: ^12.0 || ^13.0
- illuminate/validation: ^12.0 || ^13.0
- x-adam/tr-tax-number-validation: ^5.0
Requires (Dev)
- larastan/larastan: ^3.0
- orchestra/testbench: ^10.0 || ^11.0
- phpunit/phpunit: ^11.5 || ^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-19 22:02:33 UTC
README
A Laravel validation rule for Turkish tax identification numbers (Vergi Kimlik No). It wraps x-adam/tr-tax-number-validation, which checks the number offline against the official checksum rule — no network access, no dependencies beyond Laravel itself.
Requirements
| Package version | PHP | Laravel |
|---|---|---|
| 2.x | 8.2+ | 12, 13 |
| 1.x | 7.0+ | 5.5+ |
Installation
composer require x-laravel/validation-tr-tax-number-extend
The service provider is registered through package discovery.
Usage
Rule object
use XLaravel\ValidationTrTaxNumberExtend\Rules\TrTaxNumber; $request->validate([ 'tax_no' => ['required', new TrTaxNumber], ]);
The rule object comes with Turkish and English error messages and picks the one matching the application locale.
String alias
$request->validate([ 'tax_no' => ['required', 'tr_tax_number'], ]);
For the string alias Laravel resolves the error message the way it does for any extended rule, so
add a line to your application's lang/xx/validation.php:
'tr_tax_number' => ':attribute geçerli bir vergi kimlik numarası olmalıdır.',
Without it Laravel falls back to the raw key validation.tr_tax_number. You can also pass an inline
message through the validator's messages argument or a form request's messages() method.
Either form accepts int and string values; anything else — arrays, booleans, floats — fails
validation instead of throwing.
Customising the messages
To change the rule object's messages, publish the language files and edit them:
php artisan vendor:publish --tag=tr-tax-number-translations
They land in lang/vendor/tr-tax-number/{tr,en}/validation.php.
What it checks
The rule answers "is this a well-formed tax number?" — length and the check digit. It does not verify that the number is registered to a particular taxpayer; that requires querying the Revenue Administration (GİB).
Testing
composer install
composer test
composer analyse
The suite runs on Orchestra Testbench against every supported Laravel and PHP combination in CI, along with PHPStan (Larastan) at its highest level.
License
Open source software licensed under the MIT license.