<?php
“Laravel array validation”
// Laravel image validation
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
// Laravel validate integer between
'item' => 'required|integer|between:1,10',
// Laravel validation array
$data = $request->validate([
"name" => "required|array|min:3",
"name.*" => "required|string",
]);
// Validate each value from array laravel
$validator = Validator::make($request->all(), [
"names" => "required|array|min:3",
"names.*" => "required|string|distinct|min:3",
]);
// Laravel validation array
'username' => ['required', 'min:3', 'max:255', Rule::unique('users', 'username')],
// Laravel array validation
use Illuminate\Support\Facades\Validator;
$input = [
'user' => [
'name' => 'Taylor Otwell',
'username' => 'taylorotwell',
'admin' => true,
],
];
Validator::make($input, [
'user' => 'array:username,locale',
]);
0 comments:
Post a Comment
Thanks