PHP code example of eilander / validator

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

    

eilander / validator example snippets



use Eilander\Validator\LaravelValidator as Validator;

class UpdateUserValidator extends Validator
{
    protected static $rules = [
        'name'     => '


protected static $messages = [
    '


protected static $messages = [
    'email.


use \Eilander\Validator\Exceptions\ValidatorException;

class PostsController extends BaseController {

    /**
     * @var PostRepository
     */
    protected $repository;
    
    /**
     * @var PostValidator
     */
    protected $validator;

    public function __construct(PostRepository $repository, PostValidator $validator){
        $this->repository = $repository;
        $this->validator  = $validator;
    }
   
    public function store()
    {
        if ($this->validator->fails($request->all())) {
            return redirect('post/create')
                        ->withErrors($validator)
                        ->withInput();
        }

        // do something
    }
}