2

I have started to work again with Laravel(yey) and i have encountered this problem:

Argument 2 passed to Illuminate\Validation\Factory::make() must be of the type array, none given

public function submit(Request $request){

    if ($request->input('choice') == "1"){
        $validation = 'required|min:3|exists:accounts,alias';
    }
    else {
        $validation = 'required|email|exists::accounts,email';
    }

    $this->validate($request, Validator::make(array('field' => $request->input('field')), array('field' => $validation)));
}

1 Answer 1

1

It looks like you are doing it slightly wrong. I suggest you read through the validation chapter of the docs one more time.

http://laravel.com/docs/5.1/validation

However, I think this might solve your problem:

public function submit(Request $request){

    if ($request->input('choice') == "1"){
        $validation = 'required|min:3|exists:accounts,alias';
    }
    else {
        $validation = 'required|email|exists::accounts,email';
    }

    // Make sure the 'field' is set to whatever <input name="field_name"> you got
    $this->validate($request, array('field' => $validation));
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.