Evan Strat
0
Q:

valdidate laravel if falid

$validator = Validator::make($request->all(), [
    'name' => 'required|min:2|max:255'
]);

if ($validator->fails()) {
    return view('view_name');
} else {
    return view('view_name');
}
1
public function store()
{
    $this->validate(request(), [
        'song' => [function ($attribute, $value, $fail) {
            if ($value <= 10) {
                $fail(':attribute needs more cowbell!');
            }
        }]
    ]);
}
0

New to Communities?

Join the community