1. Go to this page and download the library: Download gerob/l4-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/ */
namespace App\Services\Validators;
use Crhayes\Validation\ContextualValidator;
class UserValidator extends ContextualValidator
{
protected $rules = [
'first_name' => '
use App\Services\Validators\UserValidator;
...
$userValidator = new UserValidator(Input::all());
OR
$userValidator = UserValidator::make(Input::all());
...
if ($userValidator->passes()) {
// yay, successful validation
}
// nay, get the errors
$errors = $userValidator->errors();
namespace App\Services\Validators;
use Crhayes\Validation\ContextualValidator;
class UserValidator extends ContextualValidator
{
protected $rules = [
'default' => [
'first_name' => 'd a new rule for website while editing
]
]
}
use App\Services\Validators\UserValidator;
...
$userValidator = UserValidator::make(Input::all())->addContext('create');
if ($userValidator->passes()) {
// yay, successful validation
}
// nay, get the errors
$errors = $userValidator->errors();
use App\Services\Validators\UserValidator;
$userValidator = UserValidator::make(Input::all())->addContext('edit');
if ($userValidator->passes()) {
// yay, successful validation
}
// nay, get the errors
$errors = $userValidator->errors();
use App\Services\Validators\UserValidator;
$userValidator = UserValidator::make(Input::all())
->addContext(['create', 'profile']);
// or chained
$userValidator->addContext('create')->addContext('profile');
namespace App\Services\Validators;
use Crhayes\Validation\ContextualValidator;
class UserValidator extends ContextualValidator
{
protected $rules = [
'default' => [
'first_name' => '