PHP code example of sonypradana / validator

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

    

sonypradana / validator example snippets


$val = new Validator($_POST);

$val->field('name')->f_valid(function() {
    // continue
})->else(function($err) {
    // array of error messages
    var_dump($err);
});

$is_valid = GUMP::is_valid(array_merge($_POST, $_FILES), [
    'username' => vr()->equired_file()->extension('png', 'jpg')
]);

if ($is_valid === true) {
    // continue
} else {
    // array of error messages
    var_dump($is_valid);
}

$val = new Validator($_POST);

$val->filter('name')->trim()->lowwer_case();

// run filter
$filter = $val->filter_out();

$val = new Validator($_POST);

$val->field('name')->n validation and filter
$filter = $val->failedOrFilter());