PHP code example of rifat / request-validator

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

    

rifat / request-validator example snippets




pp\RequestValidator\Validator;

$validator = new Validator;

$validator->request([
    'email'=>'test @gmal',
    'type'=>'11', 
    'money' => '2111a', 
    'zip_code' => '12q456',
    'terms' => '1212', 
    'quantity' => '20.5',
    'phone_number' => '01867s',
    'gender' => 'f',
    'username' => 'RR',
    'password' => 'qww',
]);

$rules = [
    'name' => 'uppercase',
];

// Bulk way 
$validator->rules($rules);

// Singal way
$validator->rule('name', 'as $error) {
        echo $error . "\n";
    }

    exit;
} else {
    // validation passes
    echo "Success!";
}