Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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",
]);
 
PREVIOUS NEXT
Tagged: #laravel #array #element
ADD COMMENT
Topic
Name
1+2 =