PHP code example of seorc / phpiv

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

    

seorc / phpiv example snippets





piv\ValidatorSet;
use Phpiv\ValidationError;

$validateThis = array(
    'name' => 'John Doe',
    'rating' => '6',
    'comment' => 'This is too short.',
    'email_address' => 'not an email address'
);

$vs = new ValidatorSet();

$vs->add('string', 'name')
    ->idationError $e) {
    print_r($e->getErrors());
}

/*
The output is:

Array
(
    [age] => Array
        (
            [0] => Es requerido
        )

    [rating] => Array
        (
            [0] => No puede ser mayor de 5
        )

    [comment] => Array
        (
            [0] => Debe tener 20 caracteres como mínimo
        )

    [email_address] => Array
        (
            [0] => No es un email válido
        )

)
*/