Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Latest commit

 

History

History
45 lines (32 loc) · 1.09 KB

README.md

File metadata and controls

45 lines (32 loc) · 1.09 KB

Lumen Form Request

License

Lumen Form request is a solution based on Form Request from laravel to provide modularized request validations.

Installation

Run command above do install with composer.

composer require brunocrpontes/lumen-form-request

How to use

  1. Add the following line to your app.php file:
    $app->register(LumenFormRequest\Providers\FormRequestServiceProvider::class);
  2. Create an Request class extending from FormRequest.php like above:
    <?php
    
    use LumenFormRequest\Requests\FormRequest;
    
    class ExampleFormRequest extends FormRequest {
         
        // DO YOUR VALIDATION HERE 
        public function rules() : array
        {
            return [
                'email' => 'email|required'  
            ];
        } 
    
        //IF YOU WISH RETURN WITH CUSTOM MESSAGES
        public function messages(): array 
        {
            return [
                'email.required' => 'We need to know your e-mail address!',
            ];
        }
    }