Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Method [validateRequire] does not exist

I am making a data validation, but it throws this error:

 exception 'BadMethodCallException' with message 'Method [validateRequire] does not exist.' in G:\WEB\litraen\vendor\laravel\framework\src\Illuminate\Validation\Validator.php:3265

when performing the validation.

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Validator;
use App\Http\Requests;

class UserController extends Controller
{


    public function Register(Request $request){

       $validator = Validator::make($request->all(),[
            'name' => 'required|max:25',
            'email' => 'require|email|unique:users',
            'password' => 'require|min:6'
        ]);

        if ($validator->fails()){
             return response()->json([
                 'success' => false,
                 'errors' => $validator->errors()->toArray()
             ]);
        }
           return response()->json([
                'success' => true
              ]);
        }
    }

why shows this error? that could have wrong?

Thank you :)

like image 433
Reco Jhonatan Avatar asked Jul 07 '16 03:07

Reco Jhonatan


2 Answers

SOLUTION:

'name' => 'required|max:25',
'email' => 'required|email|unique:users',
'password' => 'required|min:6'

lacked the "d"

like image 105
Reco Jhonatan Avatar answered Oct 11 '22 01:10

Reco Jhonatan


Check the validation "require", change to "required". That should allow it to run.

like image 42
Sotar Avatar answered Oct 10 '22 23:10

Sotar