PHP code example of eclemens / php-validation

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

    

eclemens / php-validation example snippets




eate validator instance
$validator = new PHPValidation\Validation();

// Add rules
$validator->rules([
    'username'   => [' => 'password']
]);

// Data
$data = [
    'username'   => 'johndoe',
    'email'      => '[email protected]',
    'password'   => 'pass1234',
    'repassword' => 'pass1234'
];

// Validate:
if ($validator->valid($data)) {
    // It's a valid data!
}




eate validator instance
$validator = new PHPValidation\Validation();

// Add rules
$validator->rules([
    'username'   => [' => 'password'],
]);

// Validate:
if ($validator->valid($_REQUEST)) {
    // It's a valid data!
}

json
{
    "clemens/php-validation": "dev-master"
    }
}