I
I
Ivan Huk2020-10-08 12:28:14
Laravel
Ivan Huk, 2020-10-08 12:28:14

How to get a key that failed validation in laravel validator?

There are rules:

$validator = Validator::make($args, [
            'place.name' => 'required|min:3|max:50',
            'place.type_id' => 'required|integer|exists:types,id',
            'kitchens' => 'array|min:1',
     ]);

Method
$validator->errors()->first();
Returns the text of the error, but I also need to get the key, for example, place.type_id

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2020-10-08
@Fragster

dd($validator->errors());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question