PHP code example of rioter / validation

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

    

rioter / validation example snippets


use Rioter\Validation\Validator;
use Rioter\Validation\Rules;


$v = new Validator();

$_POST = ['id'=>'12', 'name' => ' Alexandr'];

$v
    ->setAlias('name', 'Username')
    ->setAlias('id', 'Id пользователя')
;

$v
    ->addFunc('name', 'trim')
;

$v
    ->addRule('id', new Rules\IsNumeric())
    ->addRule('id', new Rules\IsBool())
    ->addRule('name', new Rules\MaxLength(4))
;

$v->isValid($_POST);

$v->getErrors();