PHP code example of buuum / validation

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

    

buuum / validation example snippets



$filter_rules = [
    'name'  => 'trim|sanitize_string',
    'email' => 'trim|sanitize_email',
];

$data = [
    'name' => ' name ',
    'email' => ' ([email protected]) '
];
$filter = new Filter($filter_rules);

$data = $fitler->filter($data);

// output
$data = [
    'name' => 'name',
    'email' => '[email protected]'
];

$validator_rules = [
    'name' => 'l',
    'date' => 'date:d/m/Y',
    'dia'      => 'o:mes:dia',
];

$messages = [
    "   "valid_email"   => "The :attribute format is invalid.",
    "date"          => "La fecha seleccionada es incorrecta.",
    "groupdate"     => "La fecha seleccionada es incorrecta."
];

$validator = new Validation($validator_rules, $messages);

$data = [
    'name' => '',
    'email' => ''
];

$errors = $validator->validate($data);

//outpur errors

Array
(
    [name] => Array
        (
            [0] => The name is