Answers for "how to use required_with in laravel to array element"

PHP
0

validate each value from array laravel

$validator = Validator::make($request->all(), [
    "names"    => "required|array|min:3",
    "names.*"  => "required|string|distinct|min:3",
]);
Posted by: Guest on November-12-2020
1

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.
Posted by: Guest on October-14-2020
0

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",
]);
Posted by: Guest on January-09-2021

Code answers related to "how to use required_with in laravel to array element"

Browse Popular Code Answers by Language