lloricode/php-laravel-validation

This package is abandoned and no longer maintained. No replacement package was suggested.

Extend/add some validation rules for form, in php.

v1.0.2 2017-07-18 14:24 UTC

This package is auto-updated.

Last update: 2019-10-14 23:15:51 UTC


README

Build Status

Extending you validator of you form.

Install via composer

composer require lloricode/php-laravel-validator

Laravel Integration

Provider in your config/app.php.

Lloricode\PhpLaravelValidation\PhpLaravelValidationProvider::class,

You can use this also on your native PHP codes,


require 'vendor/autoload.php';
use Lloricode\PhpLaravelvalidator\Validator;
$validator = new Validator();

// all validator return TRUE if valid, else FALSE
$valid_name     = $validator->human_name('test real name');
$valid_pass     = $validator->password_level('mysecretpassword123!@#', 5); //maximum level is 5
$valid_username = $validator->username('myusername123');

//soon
//$valid_identity = $validator->check_identity('myusername123', 'table_column', 'table_name');

// Or Better this way

$validator->set_rules([
        [
                'field'=>'name',
                'label'=>'Name',
                'rules'=>'required|human_name',
        ],
        [
                'field'=>'password',
                'label'=>'Password',
                'rules'=>'required|password_level,5',
        ],
        [
                'field'=>'username',
                'label'=>'Username',
                'rules'=>'required|username|check_identity,users,username',
        ]
]);


if($validator->check())
{
        echo 'validator DONE!';
}

echo '<pre>';
print_r($validator->errors());
echo '</pre>';
?>
<form action="" method="POST">
        <label for="name">Name</label>
        <input name="name" type="text" /><?php echo $validator->errors('name'); ?><br />

        <label for="username">Username</label>
        <input name="username" type="text" /><?php echo $validator->errors('username'); ?><br />

        <label for="password">Password</label>
        <input name="password" type="text" /><?php echo $validator->errors('password'); ?><br />

        <input type="submit" value="test"/>
</form>

Feel free to use, you can send issue,request, and suggest.

Best regrads. :)