PHP code example of fesor / symfony-validator-extra

1. Go to this page and download the library: Download fesor/symfony-validator-extra 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/ */

    

fesor / symfony-validator-extra example snippets


$rules = new FixedJson([
    'foo' => 'string',
    'bar' => 'email',
    'buz' => 'datetime',
]);

$rules = new Collection([
    'foo' => [new NotNull(), new Type('string')],
    'bar' => [new NotNull(), new Email()],
    'buz' => [new NotNull(), new DateTime()]
]);

$rules = new Collection([
    'foo' => new Optional([new NotNull(), new Type('string')])
]);

$rules = new Json([
    'foo?' => 'string'
]);

$fules = new Json([
    'foo?' = new Required([new NotNull()]),
    'bar??' => 'string',
])