PHP code example of petroslabs / fr-validator
1. Go to this page and download the library: Download petroslabs/fr-validator 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/ */
petroslabs / fr-validator example snippets
use PetrosLabs\FrValidator\Nir\NirValidator;
use PetrosLabs\FrValidator\Rib\RibValidator;
use PetrosLabs\FrValidator\Siret\SiretValidator;
use PetrosLabs\FrValidator\Iban\IbanValidator;
use PetrosLabs\FrValidator\Bic\BicValidator;
use PetrosLabs\FrValidator\Phone\PhoneValidator;
use PetrosLabs\FrValidator\Vat\VatValidator;
use PetrosLabs\FrValidator\Naf\NafValidator;
$result = (new NirValidator())->validate('1 85 03 75 116 012 16');
$result = (new RibValidator())->validate('30003 01890 00037553485 21');
$result = (new SiretValidator())->validate('732 829 320 00074');
$result = (new IbanValidator())->validate('FR76 3000 3018 9000 0375 5348 521');
$result = (new BicValidator())->validate('BNPAFRPP');
$result = (new PhoneValidator())->validate('06 12 34 56 78');
$result = (new VatValidator())->validate('FR 44 732 829 320');
$result = (new NafValidator())->validate('62.01Z');
if (!$result->isValid()) {
echo $result->failureReason()->value; // e.g. "invalid_checksum"
}
new NafValidator(additionalCodes: ['1234A']);