Git Product home page Git Product logo

tckimlikno's Introduction

TCKimlikNo

MIT Licensed Latest Version on Packagist Total Downloads Build Status Quality Score StyleCI

Turkish Identification Number Verification & Validation Package for Laravel.

Installation

Via Composer

$ composer require deligoez/tckimlikno

If you are using Laravel 5.5+, the package will automatically register the service provider for you.

Usage

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)

Available Laravel Validation Rules

TCKimlikNoVerify

// 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...
}

TCKimlikNoValidate

// In a Form Request Class

public function rules()
{
    return [
        'tckimlikno' => ['required', new TCKimlikNoValidate(
            $name,
            $surname,
            $birthYear,
            $autoUppercase // Optional, defaults to true
        )],
    ];
}

Faker Provider

use Deligoez\TCKimlikNo\Provider\TCKimlikNoFakerProvider;

$faker = Faker\Factory::create();
$faker->addProvider(new TCKimlikNoFakerProvider($faker));

// a Random Valid TCKN
$tckn = $faker->tckn; // 60174067810 

Changelog

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todo list.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.

tckimlikno's People

Contributors

deligoez avatar tkaratug avatar mecit avatar taliptako avatar frkcn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.