Search
 
SCRIPT & CODE EXAMPLE
 

PHP

validate each value from array laravel

$validator = Validator::make($request->all(), [
    "names"    => "required|array|min:3",
    "names.*"  => "required|string|distinct|min:3",
]);
Comment

laravel validation exists array

//Be careful it does multiple queries.
//'document_group_ids.*' => 'exists:document_groups,id'

public function rules(): array
{
   return [
       'document_type_id' => 'required|integer|exists:document_types,id',
       'document_group_ids' => 'required|array',
       'document_group_ids.*' => 'exists:document_groups,id',
    ];
}
Comment

laravel validation check value should be one of in array

'item' => [ Rule::in($my_arr) ],
Comment

laravel validation exists array

$request = [
    'ids' => [1, 2, 3, 4],
];

$rules = [
    'ids' => 'required|array',
    'ids.*' => 'exists:users,id', // check each item in the array
];

$validator = Validator::make($request, $rules);

dd($validator->passes(), $validator->messages()->toArray());
Comment

PREVIOUS NEXT
Code Example
Php :: php command get ini params 
Php :: php shortcode wordpress return content with shortcodes 
Php :: session start php 
Php :: post data to another page contact form 7 
Php :: laravel 8 with jetstream 
Php :: replace twig 
Php :: php slice array by key 
Php :: php array serialize 
Php :: material icons flutter list 
Php :: sort an array in php manually 
Php :: Displaying Custom Navigation Menus in WordPress Themes 
Php :: php string literal 
Php :: php display json in browser 
Php :: php null coalesce 
Php :: php exit 
Php :: integer data type php 
Php :: fillable vs guarded laravel 
Php :: Laravel - Resize image size using Laravel image class 
Php :: php join 
Php :: drop foreign key laravel eloquent 
Php :: file upload in laravel 
Php :: epoch to date php 
Php :: php file storage 
Php :: laravel create table if not exists 
Php :: php and ajax on select option 
Php :: laravel mailable from 
Php :: new order email filter woocommerce 
Php :: referencing constant in config laravel 
Php :: timezones php 
Php :: laravel migration int length 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =