48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Api\V2;
|
|
|
|
use App\Enums\Country;
|
|
use Illuminate\Validation\Rules\Password;
|
|
|
|
class StoreCustomerRequest extends BaseApiRequest
|
|
{
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'firstname' => 'required|string|min:2',
|
|
'lastname' => 'required|string|min:2',
|
|
'email' => 'required|email:rfc,dns,spoof,filter',
|
|
'password' => [
|
|
'required',
|
|
Password::min(8)
|
|
->mixedCase()
|
|
->letters()
|
|
->numbers()
|
|
->symbols()
|
|
->uncompromised()
|
|
],
|
|
'birth_date' => 'required|date_format:Y-m-d',
|
|
'address' => 'sometimes|string',
|
|
'address2' => 'sometimes|string',
|
|
'phone' => 'sometimes|string',
|
|
'country' => [
|
|
'sometimes',
|
|
//phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
|
function ($attribute, $value, $fail) {
|
|
if (!\in_array($value, Country::toValues())) {
|
|
$fail('notInList');
|
|
}
|
|
}
|
|
],
|
|
'city' => 'sometimes|string',
|
|
'postcode' => 'sometimes|string',
|
|
'opt_in' => 'required|boolean',
|
|
];
|
|
}
|
|
}
|