KD.S.T.
KD.S.T.

Reputation: 603

How to validate input name array in Laravel 5.5?

This is my input with start_date[value] :

<input type="text" class="form-control" id="inputSuccess2" placeholder="" name="start_date[value]">

This is my validation:

$validator = Validator::make($data, [
        'type'        => 'required|string',
        'def_fields'  => 'required|array',
        'def_filters' => 'required|array',
        'start_date[value]'  => 'required|array',
        'end_date[value]'    => 'required|array',
    ],[
        'def_fields.required'  => 'Report field is required',
    ]);

So far I did this:
start_date[value]
start_date.*
start_date.*.value

All of them seems to be not working.

Upvotes: 1

Views: 1647

Answers (1)

Niklesh Raut
Niklesh Raut

Reputation: 34914

You misunderstood start_date.value to put rules against and apply rule as array it would be just numeric or alpha_numeric not array , so try like

start_date.value => "required|numeric",

Or with array or min 1 element in array

start_date => "required|array|min:1"

Upvotes: 4

Related Questions