PHP code example of ekok / php-validation

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

    

ekok / php-validation example snippets




use Ekok\Validation\Validator;

$validator = new Validator();
$data = array(
    'username' => 'foo',
    'password' => 'bar',
);
$rules = array(
    'username' => 'trim|min:5',
    'password' => 'trim|min:5',
);
// any validation error will throw Ekok\Validation\ValidationException
$result = $validator->validate($rules, $data);

// $result['username'] is ok
// $result['password'] is ok