PHPackages                             laravingo/turkiye-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. laravingo/turkiye-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

laravingo/turkiye-validator
===========================

A Laravel package for Turkish specific validations.

v1.0.7(4mo ago)158[2 PRs](https://github.com/laravingo/turkiye-validator/pulls)MITPHPPHP ^8.2CI passing

Since Dec 16Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/laravingo/turkiye-validator)[ Packagist](https://packagist.org/packages/laravingo/turkiye-validator)[ RSS](/packages/laravingo-turkiye-validator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (11)Used By (0)

Turkiye Validator
=================

[](#turkiye-validator)

 [![Laravingo Turkiye Validator Cover Image](.github/assets/cover-image.png)](.github/assets/cover-image.png)

 [🇺🇸 English](README.md) | [🇹🇷 Türkçe](README.tr.md) | [🇪🇸 Español](README.es.md)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d87d5ff428fefe73d640728ac355733c48f6d7feecb6f4886cd5d0207c28f8fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176696e676f2f7475726b6979652d76616c696461746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravingo/turkiye-validator)[![GitHub Tests Action Status](https://camo.githubusercontent.com/b292df53adac0ea99be7900d1f894639ffeb320ef4cb41a35e2c664ff3ba00ad/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c61726176696e676f2f7475726b6979652d76616c696461746f722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/laravingo/turkiye-validator/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/53628ffb7c43c222baa6538749deb639e60bc15f196fb80c4a6c8d82cdcfafb1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176696e676f2f7475726b6979652d76616c696461746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravingo/turkiye-validator)[![License](https://camo.githubusercontent.com/48519027d6f76a5a937ada021f470bae9ece895babf45435fa037bb438aa07b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c61726176696e676f2f7475726b6979652d76616c696461746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravingo/turkiye-validator)

[![PHP Version](https://camo.githubusercontent.com/f09b30e1b2a1284ad64faa4b0e695b049b9d8eb7f4ff0016006888af4f45b56b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e322d3737374242342e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/f09b30e1b2a1284ad64faa4b0e695b049b9d8eb7f4ff0016006888af4f45b56b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e322d3737374242342e7376673f7374796c653d666c61742d737175617265)[![Laravel Version](https://camo.githubusercontent.com/b6c6fc0ff2b3f9f6ce91d9df8adb8719bd12e8f9b593c36584e76e2a5eabd293/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302e7825323025374325323031312e7825323025374325323031322e782d4646324432302e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/b6c6fc0ff2b3f9f6ce91d9df8adb8719bd12e8f9b593c36584e76e2a5eabd293/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302e7825323025374325323031312e7825323025374325323031322e782d4646324432302e7376673f7374796c653d666c61742d737175617265)[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)

**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
------------

[](#installation)

You can install the package via composer:

```
composer require laravingo/turkiye-validator
```

### Publishing Assets

[](#publishing-assets)

To customize the configuration or error messages, publish the assets:

```
php artisan vendor:publish --tag=turkiye-validator-config
```

---

Configuration
-------------

[](#configuration)

After publishing, you can configure the package in `config/turkiye-validator.php`:

```
return [
    // Phone format options: 'E164' (+905...), 'NATIONAL' (05...), 'RAW' (5...)
    'phone_format' => 'E164',

    // Character used for masking identity numbers
    'mask_char' => '*',
];
```

---

Validation Rules
----------------

[](#validation-rules)

This package strictly implements official mathematical algorithms (checksums, modulo checks) rather than simple regex matching.

### Available Rules

[](#available-rules)

Rule NameDescriptionExample 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.`info@company.kep.tr``city_code`Validates Turkish City Plate Codes (1-81).`34`, `6`, `81`### Usage Example

[](#usage-example)

In your Controller or Form Request:

```
$request->validate([
    'identity_number' => 'required|turkish_id',
    'phone'           => 'required|turkish_phone',
    'tax_number'      => 'nullable|tax_id',
    'plate_code'      => 'required|license_plate',
    'iban'            => 'required|turkish_iban',
    'serial_no'       => 'required|tr_id_card_serial',
    'kep_email'       => 'required|kep_address',
    'city'            => 'required|city_code',
]);
```

---

Address &amp; Data Service
--------------------------

[](#address--data-service)

The package includes a data service to easily access official lists of Turkish cities and districts.

### Usage

[](#usage)

```
use Laravingo\TurkiyeValidator\Facades\Turkiye;

// Get All Cities (Plate Code => Name)
$cities = Turkiye::cities();
// Returns: [1 => 'Adana', ..., 34 => 'İstanbul', ...]

// Get Districts for a City (by Plate Code)
$districts = Turkiye::districts(34);
// Returns: ['Adalar', 'Arnavutköy', 'Ataşehir', ...]
```

---

Helper Functions
----------------

[](#helper-functions)

Utility helpers are available via the `Turkiye` facade to format and mask sensitive data.

### Phone Formatting

[](#phone-formatting)

```
// Input can be messy: "0532 123 45 67" or "532-123-4567"
$formatted = Turkiye::formatPhoneNumber('0532 123 45 67');

// Output depends on 'phone_format' config:
// 'E164':     "+905321234567" (Default)
// 'NATIONAL': "05321234567"
// 'RAW':      "5321234567"
```

### Identity Masking

[](#identity-masking)

```
$masked = Turkiye::maskIdentityNumber('12345678901');

// Output (based on 'mask_char'): "123******01"
```

---

Sanitization &amp; Helper
-------------------------

[](#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

[](#usage-1)

```
use Laravingo\TurkiyeValidator\Utilities\TurkishSanitizer;

$sanitizer = new TurkishSanitizer();

// Title Case (Correctly handles i/İ/I/ı)
echo $sanitizer->toTitle('i̇stanbul ve IĞDIR');
// Output: "İstanbul Ve Iğdır"

// Clean Phone Number (Returns pure 10 digits)
echo $sanitizer->cleanPhone('0 (555) 123-45 67');
// Output: "5551234567"

// Clean IBAN (Uppercase + No Spaces)
echo $sanitizer->cleanIban('tr 12 34 56...');
// Output: "TR123456..."
```

---

Eloquent Casts (Pro Feature)
----------------------------

[](#eloquent-casts-pro-feature)

Automatically clean and format your data *before* it is saved to the database using Laravel Custom Casts.

### Usage in Model

[](#usage-in-model)

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Laravingo\TurkiyeValidator\Casts\TurkishPhoneCast;
use Laravingo\TurkiyeValidator\Casts\TurkishIbanCast;
use Laravingo\TurkiyeValidator\Casts\TurkishTitleCast;

class User extends Model
{
    protected $casts = [
        'phone'      => TurkishPhoneCast::class, // Auto-cleans to 10 digits
        'iban'       => TurkishIbanCast::class,  // Uppercase + No Spaces
        'full_name'  => TurkishTitleCast::class, // Auto-converts to Title Case (Turkish logic)
    ];
}
```

Now, when you do `$user->phone = '(555) 123'; $user->save();`, it saves `555123...` to the DB.

---

Faker Provider (Testing)
------------------------

[](#faker-provider-testing)

We automatically register a Faker provider so you can generate **mathematically valid** test data in your factories and seeds.

### Usage

[](#usage-2)

```
// In a Factory or Seeder
$validId    = fake()->turkishIdNumber();    // Valid checksum
$validIban  = fake()->turkishIban();        // Valid TR IBAN
$validTax   = fake()->turkishTaxIdNumber(); // Valid VKN
$validPlate = fake()->turkishLicensePlate();// Valid 06 ABC 123
$validPhone = fake()->turkishPhoneNumber(); // Valid +905...
```

---

Localization
------------

[](#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`:

```
'locale' => 'tr',
```

The error messages will automatically switch to Turkish (e.g., "Geçerli bir T.C. Kimlik Numarası olmalıdır").

---

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/laravingo/turkiye-validator/blob/main/LICENSE.md) for more information.

---

Testing
-------

[](#testing)

This package uses [Pest PHP](https://pestphp.com) for automated testing.

```
composer test
```

To run specific tests:

```
vendor/bin/pest --filter=ValidationRulesTest
```

###  Health Score

41

—

FairBetter than 88% of packages

Maintenance80

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

8

Last Release

142d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/db88c84504771bba43f8f438262c52ecc719e53c49352cb932bd63309838d4ae?d=identicon)[ibrahimoglakci](/maintainers/ibrahimoglakci)

---

Top Contributors

[![ibrahimoglakci](https://avatars.githubusercontent.com/u/117722429?v=4)](https://github.com/ibrahimoglakci "ibrahimoglakci (1 commits)")

---

Tags

laravellaravel-packagelaravingolocalizationpackagedevelopmentphpsanitizationtcknturkiyevalidationvkn

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/laravingo-turkiye-validator/health.svg)

```
[![Health](https://phpackages.com/badges/laravingo-turkiye-validator/health.svg)](https://phpackages.com/packages/laravingo-turkiye-validator)
```

###  Alternatives

[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k6.0M60](/packages/spatie-laravel-honeypot)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[sunspikes/clamav-validator

Custom Laravel 5 anti-virus validator for file uploads.

3651.8M3](/packages/sunspikes-clamav-validator)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
