<?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
'username' => ['required', Rule::unique('users', 'username')],