PHP code example of b-tokman / validation

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

    

b-tokman / validation example snippets


class BaseObject
{
    use bTokman\validation\ValidationTrait;
}

......

class ValidationObject extends BaseObject
{
    public $validationRules = [
        'password' => [NotBlank::class, [Length::class, ['min' => 8]]],
    ];

    public $password;
}

......

$object = new ValidationObject();
   
$result = $object->validate();




class ValidationObject
{
    use bTokman\validation\ValidationTrait;

    public function __construct()
    {
        $this->validationRules = [
            'password' => [NotBlank::class, [Length::class, ['min' => 8]]],
        ];
    }
    
    public $password;
}

$object = new ValidationObject();
   
$result = $object->validate();