PHP code example of tyurderi / validator

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

    

tyurderi / validator example snippets

 php
$v = new Validator\Validator();

$v->addRule('unique_username', function($fields, $value, $params) {
    // logic goes here
    return true;
});

$v->add('username', 'tyurderi', 'at most 30 characters long.',
    'unique_username' => 'The username is already in use.'
));

$v->validate();

if ($v->passes())
{
    echo 'Validation was successfully!';
}
else
{
    echo 'Validation failed.', PHP_EOL;
    foreach ($v->errors() as $message)
    {
        echo $message, PHP_EOL;
    }
}