Skip to content

alaa-almaliki/php-input-validation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Input Validation

Based on Respect Validation

See full list of Rule Validators

Installation

Use composer composer require alaa-almaliki/php-input-validation: v1.0.0

Example

require_once __DIR__ . '/vendor/autoload.php';

$validation = new \Rv\InputValidation\Validation();

$isValid = $validation->validate(
    '21',
    [
        ['class' => 'Between', 'args' => ['min' => 16, 'max' => 22]],
        ['class' => 'NotEmpty']
    ]
);

$isValidEmail = $validation->validate(
    '[email protected]',
    [
        ['class' => 'NotEmpty'],
        ['class' => 'Email'],
    ]
);

$emailPostResults = $validation->validatePostData(
    ['email' => '[email protected]'],
    [
        'email' => [
            [
                'class' => 'Email',
                'success_message' => 'Valid Email',
                'failure_message' => 'Not Valid Email',
            ],
        ],
    ]
);


$emailParamResults = $validation->validateGetData(
    ['email' => '[email protected]'],
    [
        'email' => [
            [
                'class' => 'Email',
                'success_message' => 'Valid Email',
                'failure_message' => 'Not Valid Email',
            ],
        ],
    ]
);
var_dump($isValid);
var_dump($isValidEmail);
var_dump($emailPostResults);
var_dump($emailParamResults);