PHP code example of caridea / validate

1. Go to this page and download the library: Download caridea/validate 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/ */

    

caridea / validate example snippets


$registry = new \Caridea\Filter\Registry();
$builder = $registry->builder();
$ruleset = json_decode(file_get_contents('rules.json'));
$validator = $builder->build($ruleset);

$registry = new \Caridea\Filter\Registry();
$builder = $registry->builder();
$validator = $builder->field('name', 'one', ['max_length' => 10])
    ->build();

$input = [
    'foo' => 'bar',
    'abc' => '123',
];
$result = $validator->validate($input);
// or
$validator->assert($input);

$registry = new \Caridea\Validate\Registry();
$registry->register([
    'credit_card' => ['MyCustomRules', 'getCreditCard'], // a static method
]);