ldc-crm/app/Http/Requests/Api/V2/StoreCustomerRequest.php

49 lines
1.5 KiB
PHP
Raw Normal View History

2021-03-14 10:45:42 +01:00
<?php
namespace App\Http\Requests\Api\V2;
2021-03-14 10:45:42 +01:00
use App\Enums\Country;
use Illuminate\Validation\Rules\Password;
2021-03-14 10:45:42 +01:00
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',
2021-03-14 10:45:42 +01:00
'password' => [
'required',
Password::min(8)
->mixedCase()
->letters()
->numbers()
->symbols()
->uncompromised()
2021-03-14 10:45:42 +01:00
],
'birth_date' => 'required|date_format:Y-m-d',
'address' => 'sometimes|string',
'address2' => 'sometimes|string',
'phone' => 'sometimes|string',
2021-03-14 10:45:42 +01:00
'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',
2021-03-14 10:45:42 +01:00
];
}
}