PHP code example of samrap / laravel-validation

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

    

samrap / laravel-validation example snippets


public function store(Request $request, ModelValidator $validator)
{
    $validator = $validator->validate($request->all());
    $this->validateWith($validator, $request);

    ...
}

Samrap\Validation\ValidationServiceProvider::class

namespace App\Validators;

use App\Validators\Validator;

class UserValidator extends Validator
{
    /**
     * The validation rules.
     *
     * @var array
     */
    protected $rules = [];
}

/**
 * The validation rules.
 *
 * @var array
 */
protected $rules = [
    'email' => 'email|

public function store(Request $request, UserValidator $validator)
{
    $validator = $validator->validate($request->all());
    $this->validateWith($validator, $request);

    ...
}

public function store(Request $request, UserValidator $validator)

$validator = $validator->validate($request->all());

$validator = $validator->validate($request->all(), [
    'name' => 'string|

protected $updating = [
    // rules...
];

public function update(Request $request, UserValidator $validator)
{
    $validator = $validator->using('updating')->validate($request->all());
    $this->validateWith($validator, $request);

    ...
}

$this->validateWith($validator, $request);