[Vuejs]-How to validate Dynamic input in vuejs / Laravel

0👍

I hope this is what you wanted to achieve.

public function store(Request $request)
{

    $rules = [
        'userinputs.*.name' => 'required|max:255',
    ];

    $validator = \Illuminate\Support\Facades\Validator::make($request->all(), $rules);

    if ($validator->fails()) {
        //Return the errors as JSON
        return response()->json(['success' => 'false', 'errors' => $validator->errors()], 400);
    }

    //Do something

    return ['success' => 'true'];
}

Leave a comment