PHP code example of geofmureithi / f3-validate

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

    

geofmureithi / f3-validate example snippets


class Profile
{
    use Validate; //<--- Trait

    public function getRules()
    {
        return [
            "email" => "reqired|email"
        ];
    }
    
    public function save()
    {
        //.....
    }
}

$data = $f3->get('POST')
$profile = new Profile();
$result = $profile->check($data);
if( $result != true) return $result; //errors
$profile->save();

$message = "The value of {0} must include each of these items : {1}";
Validate::addValidator("contains", function ($value, $ruleConfigs) {
  $Class::testCustom", "Custom Error");
bash
./vendor/bin/phpunit --bootstrap vendor/autoload.php --testdox tests