Download the PHP package laravingo/turkiye-validator without Composer
On this page you can find all versions of the php package laravingo/turkiye-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laravingo/turkiye-validator
More information about laravingo/turkiye-validator
Files in laravingo/turkiye-validator
Package turkiye-validator
Short Description A Laravel package for Turkish specific validations.
License MIT
Informations about the package turkiye-validator
Turkiye Validator
🇺🇸 English | 🇹🇷 Türkçe | 🇪🇸 Español
The ultimate Swiss Army Knife for Turkish data validation, sanitization, and testing in Laravel.
This package provides a comprehensive suite of validation rules (Official Algorithms), sanitization utilities, Eloquent casts, and Faker providers specifically tailored for Turkish data requirements (Identity Numbers, VKN, License Plates, IBAN, KEP, etc.).
Installation
You can install the package via composer:
Publishing Assets
To customize the configuration or error messages, publish the assets:
Configuration
After publishing, you can configure the package in config/turkiye-validator.php:
Validation Rules
This package strictly implements official mathematical algorithms (checksums, modulo checks) rather than simple regex matching.
Available Rules
| Rule Name | Description | Example Input |
|---|---|---|
turkish_id |
Validates T.C. Identity Number (11 digits, Algo Check). | 10000000146 |
turkish_phone |
Validates Turkish Mobile Numbers. | 555 123 45 67 or 0555... |
tax_id |
Validates Tax ID (Vergi Kimlik No, 10 digits, Mod-10). | 1234567890 |
license_plate |
Validates Turkish License Plates (City Code 01-81). | 34 ABC 123 |
turkish_iban |
Validates Turkish IBANs (TR prefix + Mod-97 checksum). | TR12000... |
tr_id_card_serial |
Validates New Identity Card Serial Numbers. | A12F34567 |
kep_address |
Validates Registered Electronic Mail (KEP) addresses. | [email protected] |
city_code |
Validates Turkish City Plate Codes (1-81). | 34, 6, 81 |
Usage Example
In your Controller or Form Request:
Address & Data Service
The package includes a data service to easily access official lists of Turkish cities and districts.
Usage
Helper Functions
Utility helpers are available via the Turkiye facade to format and mask sensitive data.
Phone Formatting
Identity Masking
Sanitization & Helper
The package provides a TurkishSanitizer class (and a Turkiye facade) to clean messy input. It explicitly handles Turkish character conversion (i/İ/I/ı) correctly, regardless of server locale.
Usage
Eloquent Casts (Pro Feature)
Automatically clean and format your data before it is saved to the database using Laravel Custom Casts.
Usage in Model
Now, when you do $user->phone = '(555) 123'; $user->save();, it saves 555123... to the DB.
Faker Provider (Testing)
We automatically register a Faker provider so you can generate mathematically valid test data in your factories and seeds.
Usage
Localization
The package supports English (en) and Turkish (tr) out of the box.
To change the language, simply set your Laravel app locale in config/app.php:
The error messages will automatically switch to Turkish (e.g., "Geçerli bir T.C. Kimlik Numarası olmalıdır").
License
The MIT License (MIT). Please see License File for more information.
Testing
This package uses Pest PHP for automated testing.
To run specific tests: