Turkish Identification Number Verification & Validation Package for Laravel.
Via Composer
$ composer require deligoez/tckimlikno
If you are using Laravel 5.5+, the package will automatically register the service provider for you.
use Deligoez\TCKimlikNo\TCKimlikNo;
// Verifies Citizenship Number According to it's Algorithm.
// Returns Boolean
TCKimlikNo::verify('12345678901'); // Returns false
TCKimlikNo::verify('10000000146'); // Returns true
// Verifies Parameters and validates all using nvi.gov.tr API
// Returns Boolean
TCKimlikNo::validate('10000000146', 'Yunus Emre', 'Deligöz', '1900')
// Auto Uppercase Disabled
TCKimlikNo::validate('10000000146', 'YUNUS EMRE', 'DELİGÖZ', '1900', false)
// In a Form Request Class
public function rules()
{
return [
'tckimlikno' => ['required', new TCKimlikNoVerify()],
];
}
// In a Controller
use Deligoez\TCKimlikNo\Rules\TCKimlikNoVerify;
/**
* Store a tckn.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$validatedData = $request->validate([
'tckn' => ['bail', 'required', new TCKimlikNoVerify()],
]);
// tckn is valid...
}
// In a Form Request Class
public function rules()
{
return [
'tckimlikno' => ['required', new TCKimlikNoValidate(
$name,
$surname,
$birthYear,
$autoUppercase // Optional, defaults to true
)],
];
}
use Deligoez\TCKimlikNo\Provider\TCKimlikNoFakerProvider;
$faker = Faker\Factory::create();
$faker->addProvider(new TCKimlikNoFakerProvider($faker));
// a Random Valid TCKN
$tckn = $faker->tckn; // 60174067810
Please see the changelog for more information on what has changed recently.
$ composer test
Please see contributing.md for details and a todo list.
If you discover any security related issues, please email ye@deligoz.me instead of using the issue tracker.
MIT. Please see the license file for more information.