PHP code example of sandermuller / laravel-fluent-validation

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

    

sandermuller / laravel-fluent-validation example snippets


// Before
'name'         => '', 'email', Rule::unique('users')->ignore($id)],
'role'         => Rule::when($isAdmin, 'ax:255',

// After
'name'  => FluentRule::string('Full Name')->in(['admin', 'editor'])),
'items' => FluentRule::array()->each([
    'id'   => FluentRule::integer()->

use Illuminate\Foundation\Http\FormRequest;
use SanderMuller\FluentValidation\FluentRule;
use SanderMuller\FluentValidation\HasFluentRules;

class StorePostRequest extends FormRequest
{
    use HasFluentRules;

    public function rules(): array
    {
        return [
            'title'    => FluentRule::string('Title')->                         FluentRule::string()->max(50)
                          ),
            'password' => FluentRule::password()->