PHP code example of olssonm / identity-number

1. Go to this page and download the library: Download olssonm/identity-number library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

olssonm / identity-number example snippets



use Olssonm\IdentityNumber\IdentityNumberFormatter;

// Format to a 10-character PIN without a seperator
$formatter = new IdentityNumberFormatter('19860210-7313', 10, false);

// Get the formatted output
$formatter->getFormatted(); // 8602107313

// You can also clean the number from all unwanted characters
(new IdentityNumberFormatter('a19860210 - 7313', 12, true))->clean()->getFormatted(); // 19860210-7313
 php
'providers' => [
    Olssonm\IdentityNumber\IdentityNumberServiceProvider::class,
]
 php
Pin::isValid('19771211-2775'); // Defaults to identity number
// true

Pin::isValid('19771211-2775', 'identity'); // Identity validation specified
// true
 php
Pin::isValid('556016-0681', 'organization')
// true
 php
Pin::isValid('19671180-2850', 'coordination');
// true
 php
// Personal identity numbers
public function store(Request $request) {
    $this->validate($request, [
        'number' => '> '
 php
$validator = Validator::make($request->all(), [
    'number' => '!"
]);

if($validator->fails()) {
    return $this->returnWithErrorAndInput($validator);
}