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

81 lines
2 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'
],
'password' => [
'required',
Password::min(10)
->mixedCase()
->letters()
->numbers()
->symbols()
->uncompromised()
2021-03-14 10:45:42 +01:00
],
'birth_date' => [
'required',
'date_format:Y-m-d'
],
'address' => [
'required',
'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' => [
'required',
'string'
],
'postcode' => [
'required',
'string'
],
'opt_in' => [
'required',
'boolean'
],
];
}
}