1

I am new learner of laravel.Now I have to use the laravel validation in my project.The data from the form is two-dimensional array in the follwing format:

[['product_id'=>1, 'quantity'=>2], ['product_id' => 4, 'quantity'=>5]]

I need to validate every product_id, how should I write the validation rule? thank you!

1
  • 1
    It is clearly mention in laravel doc, did you search for this ? Commented May 22, 2018 at 3:29

1 Answer 1

1

This will validate the product_id field of each associative array within the form data.

$validator = Validator::make($request->all(), [
    '*.product_id' => // your validation rule
]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.