Download the PHP package olssonm/identity-number without Composer
On this page you can find all versions of the php package olssonm/identity-number. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download olssonm/identity-number
More information about olssonm/identity-number
Files in olssonm/identity-number
Package identity-number
Short Description Laravel validator for Swedish personal identity numbers / social security numbers (personnummer)
License MIT
Homepage https://github.com/olssonm/identity-number
Informations about the package identity-number
Swedish "personnummer" validator for Laravel
⚠️ Abandoned This package has been abandoned in favor of olssonm/swedish-entity.
While the package will be usable for the forseeable future, it will not be updated. Please migrate to olssonm/swedish-entity
when possible.
Validator for Swedish "personnummer" (a.k.a. personal identity number, social security number or simply "PIN").
This validator also handles Swedish organization numbers and the temporary personal identity number known as "Samordningsnummer" (a.k.a. coordination number).
For use either as a standalone package, or with Laravel.
The package does not only apply the Luhn-algorithm for the last four digits, but also checks that the date of birth is a valid date.
Of course you can throw pretty much any format you wish at the validator, ie. 10-digit variant (7712112775
) or the 12-digit variant (197712112775
) and with or without a hyphen (771211-2775
, 19771211-2775
).
Install
Via Composer
Within Laravel
This package uses Package Auto-Discovery for loading the service provider. Once installed you should see the message
Else, per standard Laravel-procedure, just register the package in your providers array:
Usage
Standalone
The package is usable straight out of the box once installed with composer:
Personnummer ("personal identity number")
Organisationsnummer ("organization number")
Samordningsnummer ("coordination number")
The coordination-number validator handles the same way as the personal identity-validator but does not run a check/validation on the date of birth.
The IdentityNumberFormatter-class
The IdentityNumberFormatter-class allows you to format a PIN/identity for your custom needs. The class is also used internally for validation, but if you want to make sure you save the same value in the database as you pass for validation – you should also apply the formatting before validating.
Laravel validators
The package extends the Illuminate\Validator
via a service provider, so all you have to do is use the identity_number
-, coordination_number
- and organization_number
-rules, just as you would with any other rule.
And of course, you can roll your own error messages:
If you're using the validation throughout your application, you also might want to put the error message in your lang-files.
Testing
or
License
The MIT License (MIT). Please see License File for more information.
© 2020 Marcus Olsson.