mardi 5 juin 2018

laravel how to validate array index and values

I am submitting a single dimensional array of values to process on laravel 5.6

quantity[4]:11
quantity[2]:14

I have to validate both the index and the value, index should exits as stocks,id and value must be integer and minimum 1

I tried

public function rules()
{
    $rules = [
       'quantity.*' => 'exists:stocks,id',
       'quantity' => 'required|integer|min:1',
    ];

    return $rules;
}

but its validating only the values not index, please share your thoughts and comments.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire