4
votes

when i submit a form and run form validation then it gaves me this error but my form validation is working on other page In that file \vendor\laravel\framework\src\Illuminate\Validation\Validator.php

/**
 * Handle dynamic calls to class methods.
 *
 * @param  string  $method
 * @param  array   $parameters
 * @return mixed
 *
 * @throws \BadMethodCallException
 */
public function __call($method, $parameters)
{
    $rule = Str::snake(substr($method, 8));

    if (isset($this->extensions[$rule])) {
        return $this->callExtension($rule, $parameters);
    }

    throw new BadMethodCallException(sprintf(
        'Method %s::%s does not exist.', static::class, $method
    ));
}

Errror= Method Illuminate\Validation\Validator::validateRequest does not exist

4
Can you show us the code that raises the error? - S. Dev
Well i found the error it is in my validation rules - Daniel Masih

4 Answers

17
votes

Maybe you wrote request instead of required? Like here:

$data = $request->validate([
    'field' => 'request|string|max:255',
]);

Trying to fire validateRequest method suggest you were trying to use 'request' validation rule which doesn't exist.

All valid rules you can find here, but I think you just made a typo.

2
votes

You should use a Validator facade class

In you Controller

use Validator;

See link Laravel validation

0
votes

You can validate the form as below:

public function formSubmit(Request $request){
    $request->validate([
        'name' => 'required',
        'address' => 'required',
        'phone' => 'required',
    ]);

    $customer =Customer::insert([
        'name' => $request->name,
        'address' => $request->address,
        'phone' => $request->phone
    ]);
    dd($customer);
    echo "Data send Successfully";
}
0
votes

you may try this method

$request->validate([
        'sex' => ['required',Rule::in('f','m')]
        ]);

this one is worked for me