PHP code example of experience / validation

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

    

experience / validation example snippets


$rules = ['username' => '

// The user ID is 1234.
$rules = ['username' => '

$createRules = ['username' => ''

'providers' => [
    // ...
    'Experience\Validation\ValidationServiceProvider',
];

 namespace Acme\Validators;

use Experience\Validation\Validators\Validator;

class RegistrationValidator extends Validator
{
    /**
     * Validation rules for creating an account.
     *
     * @var array
     */
    protected $createRules = [
        'username' => ' ];
}

use Acme\Validators\RegistrationValidator;
use Experience\Validation\Exceptions\ValidationException;

// ...

protected $validator;

public function __construct(RegistrationValidator $validator)
{
    $this->validator = $validator;
}

public function store()
{
    $input = Input::all();

    try {
        $this->validator->validateForCreate($input);
    } catch (ValidationException $e) {
        return Redirect::back()
            ->withInput()
            ->withErrors($e->getErrors());
    }
}

public function update($id)
{
    $input = Input::all();
		
    try {
        $this->validator->validateForUpdate($input, $id);
    } catch (ValidationException $e) {
        return Redirect::back()
            ->withInput()
            ->withErrors($e->getErrors());
    }
}

 namespace Acme\Validators;

use Experience\Validation\Validators\Validator;

class SessionValidator extends Validator
{
	protected $createRules = [
	    'username' => '

$this->sessionValidator->validateForCreate(Input::all());