Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel validation array unique values

<?php
$validator = Validator::make($request->all(), [
  'myArray' => ['required', 'array', 'min:1', 'max:100', 'distinct'],
  'myArray.*' => ['required', 'integer', 'min:1', 'max:999999']
]);

if ($validator->fails()) {
  return [
    'status' => 400,
    'response' => $validator->errors()
  ];
}

$validated = $validator->validated();

// distinct is there for the uniqunes
Comment

laravel validate form data unique array

'username' => ['required', Rule::unique('users', 'username')],
Comment

PREVIOUS NEXT
Code Example
Php :: php array length for loop 
Php :: how to install php dependencies 
Php :: laravel check if exists in table 
Php :: php session destroy 
Php :: send html email laravel 
Php :: Yii::app()-request-get yii1 
Php :: laravel collection sum array column 
Php :: laravel unique column except self 
Php :: laravel custom log 
Php :: php program to find factorial of a number using function 
Php :: unable to open file error in php 
Php :: base64 enocode php 
Php :: fetch data from live website curl php 
Php :: laravel validation regex 
Php :: laravel findorfail 
Php :: collapse open by default 
Php :: check if elquent retrun empty array laravel 
Php :: php array sort by key value 
Php :: php recursive function to build array 
Php :: pdo php search table 
Php :: php check if object is empty 
Php :: How to get route parameter in blade? 
Php :: php echo sql result 
Php :: Allowed memory size of 1610612736 bytes exhausted 4096 
Php :: laravel 6 tymon/jwt-auth 
Php :: get 10 value in array php 
Php :: php take picture with mobile camera 
Php :: php array loop 
Php :: rand string php 
Php :: yii2 dataprovider to model 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =