78 lines
1.9 KiB
PHP
78 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Api\V2;
|
|
|
|
use App\Enums\Country;
|
|
|
|
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',
|
|
'case_diff',
|
|
'numbers',
|
|
'letters',
|
|
'symbols',
|
|
'min:10'
|
|
],
|
|
'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'
|
|
],
|
|
];
|
|
}
|
|
}
|