validate each value from array laravel
$validator = Validator::make($request->all(), [
"names" => "required|array|min:3",
"names.*" => "required|string|distinct|min:3",
]);
validate each value from array laravel
$validator = Validator::make($request->all(), [
"names" => "required|array|min:3",
"names.*" => "required|string|distinct|min:3",
]);
required_without_all laravel
1. required_with:foo,bar,...
Use Case: The field under validation must be present and not empty only if any
========= of the other specified fields are present.
2. required_with_all:foo,bar,...
Use Case: The field under validation must be present and not empty only if all
========= of the other specified fields are present.
3. required_without:foo,bar,...
Use Case: The field under validation must be present and not empty only when
======== any of the other specified fields are not present.
4. required_without_all:foo,bar,...
Use Case: The field under validation must be present and not empty only when
========= all of the other specified fields are not present.
how to use required_with in laravel to array element
$validator = Validator::make($request->all(), [
"currency" => "nullable|required_with:price.*|string",
//or if you want to check currency for first price then use
// "currency" => "nullable|required_with:price.0|string",
"price" => "required|array|min:3",
"price.*" => "required|string|distinct|min:3",
]);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us