samedi 28 avril 2018

How do I add a custom rule into customRequest laravel?

Is there a way to use the Custom Validation Rules https://laravel.com/docs/5.5/validation#custom-validation-rules

when using the Form Request?

I do not see it anywhere in the docs, and only similar questions on the web with no answer.

Example:

php artisan make:rule Uppercase

CustomRequest.php

use App\Rules\Uppercase;

protected $rules = [

      'Names' => ['required','string', new Uppercase],
]

UserController.php

public funcion store(CustomRequest $Request)
{

}

Any ideas anyone?

message Constant expression contains invalid operations exception Symfony\Component\Debug\Exception\FatalErrorException file C:\xampp\htdocs\jireh\app\Http\Requests\CustomRequest.php line: 22




Aucun commentaire:

Enregistrer un commentaire