PHP code example of mivir / pupil

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

    

mivir / pupil example snippets


$pupil = new \Mivir\Pupil\Pupil();
$pupil->validate($rules, $values);

$rules = array(
	'name' => 'min(3) && max(8) && regex("^[a-zA-Z]+$")',
	'country' => 'min(2)'
);

$values = array(
	'name' => $nameInput,
	'country' => $countryInput
);

isValid()   // Whether the validation was successful or not
hasErrors() // The opposite of isValid()
errors()    // Returns the fields that didn't pass validation
fields()    // Returns all of the fields and their validation results

array(
	'state' => 'otherEquals("country", "US") ? lenMin(2) : lenMin(0)'
)

$pupil->addFunction($name, $callable);

customFunction("arg1", "arg2")