This small library helps you to validate Swiss Social Security Numbers (AVS / AHV). It will check against regex and checksums to be sure that the number is valid.
You can install the package via composer:
composer require patrickjunod/avs-checkerYou can use the AVS Checker as a standalone PHP Package:
use PatrickJunod\AvsChecker\AvsChecker;
$avsNumber = new AvsChecker('756.3026.0705.92');
$avsNumber->isValid();
// Return true if it's a valid AVS Number, false if notOr use it with a facade:
use PatrickJunod\AvsChecker\Facades\AvsChecker;
$avsNumber = AvsChecker::isValid('756.3026.0705.92');
// Return true if it's a valid AVS Number, false if notYou can also validate AVS numbers without dots separation by passing false parameter to the isValid method. This option will validate AVS numbers with AND without dots.
use PatrickJunod\AvsChecker\AvsChecker;
$avsNumber = AvsChecker::isValid('7563026070592', false);
// Return trueYou can also validate an array of AVS numbers - with or without strict mode
use PatrickJunod\AvsChecker\AvsChecker;
$avsNumber = AvsChecker::isValid(['7563026070592', '756.2036.0705.92', 'AAA'], false);
// Return an array:
[
0 => [
"number" => "7563026070592",
"isValid" => true
],
1 => [
"number" => "756.2036.0705.92",
"isValid" => true
],
2 => [
"number" => "AAA",
"isValid" => false
]
]composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.