I'm having a problem with the genre
column during my form validation tests: Method Illuminate\Validation\Validator::validateEnum does not exist.
FighterRequest.php
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class FighterRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
'name' => 'required|max:30',
'martial_art' => 'required|max:50',
'nationality' => 'required|max:30',
'genre' => 'required|enum',
'height' => 'required|numeric',
'weight' => 'required|numeric',
];
}
public function messages()
{
return[
'name.required' => 'It's mandatory to define the name of the Fighter..',
'name.max' => 'Fighter name must contain a maximum of 30 characters.',
'martial_art.required' => 'It's mandatory to define the martial art of the Fighter.',
'martial_art.max' => 'Fighter martial art must contain a maximum of 50 characters.',
'nacionality.required' => 'It's mandatory to define the nationality of the Fighter.',
'nacionality.max' => 'The Fighter's nationality must contain a maximum of 30 characters.',
'genre.required' => 'It's mandatory to set the Fighter genre.',
'genre.enum' => 'Fighter gender must be Male or Female.',
'height.required' => 'It's mandatory to set the height of the Fighter.',
'height.numeric' => 'Fighter height must be a numeric value.',
'weight.required' => 'It is mandatory to set the Fighter weight.',
'weight.numeric' => 'Fighter weight must be a numeric value.',
];
}
}