PHP code example of petroslabs / fr-validator-symfony

1. Go to this page and download the library: Download petroslabs/fr-validator-symfony 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-symfony example snippets


use PetrosLabs\FrValidatorSymfony\Constraints as Assert;

final class CompanyProfile
{
    #[Assert\Siret]
    public string $siret;

    #[Assert\Iban]
    public string $iban;

    #[Assert\Vat(message: 'This VAT number looks wrong: {{ reason }}')]
    public string $vatNumber;

    #[Assert\Naf(additionalCodes: ['9999Z'])]
    public string $nafCode;
}

$violations = $validator->validate($companyProfile);

foreach ($violations as $violation) {
    $violation->getCode(); // e.g. "invalid_checksum", "unknown_code"
}