PHP code example of shippeo / valitron

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

    

shippeo / valitron example snippets


$v = new Valitron\Validator(array('name' => 'Chester Tester'));
$v->rule('ors
    print_r($v->errors());
}

$v = new Valitron\Validator($_POST);
$v->rule(' {
    echo "Yay! We're all good!";
} else {
    // Errors
    print_r($v->errors());
}

$v = new Valitron\Validator(array('settings' => array(
    array('threshold' => 50),
    array('threshold' => 90)
)));
$v->rule('max', 'settings.*.threshold', 100);
if($v->validate()) {
    echo "Yay! We're all good!";
} else {
    // Errors
    print_r($v->errors());
}


// boot or config file

use Valitron\Validator as V;

V::langDir(__DIR__.'/validator_lang'); // always set langDir before lang.
V::lang('ar');


$v->rule('creditCard', 'credit_card');

$v->rule('creditCard', 'credit_card', ['visa', 'mastercard']);

$v->rule('creditCard', 'credit_card', 'visa');

$cardType = 'amex';
$v->rule('creditCard', 'credit_card', $cardType, ['visa', 'mastercard']);
$v->validate(); // false

Valitron\Validator::addRule('alwaysFail', function($field, $value, array $params, array $fields) {
    return false;
}, 'Everything you do is wrong. You fail.');

$rules = [
    '=> 'bar',
    'integer' =>  'bar'
];

$v = new Valitron\Validator(array('foo' => 'bar', 'bar' => 1));
$v->rules($rules);
$v->validate();

$rules = [
    ',
        ['bar']
    ],
    'length' => [
        ['foo', 3]
    ]
];

$rules = [
    'length'   => [
        ['foo', 5],
        ['bar', 5]
    ]
];

$rules = [
    '=> 'bar',
    'integer' =>  'bar'
];

$v = new Valitron\Validator(array('foo' => 'bar', 'bar' => 1));
$v->rules($rules);
$v->rule('min', 'bar', 0);
$v->validate();

$v = new Valitron\Validator(array());
$v->rule('

$v = new Valitron\Validator(array());
$v->rule('

$v = new Valitron\Validator(array());
$v->rule('ail' => 'Email address'
));
$v->validate();

curl -s http://getcomposer.org/installer | php
php composer.phar