fix: 🐛 add array merge in listenFormRequest to have correct validation
This commit is contained in:
parent
a424fc724d
commit
8cfc757995
1 changed files with 16 additions and 18 deletions
|
|
@ -40,24 +40,22 @@ class ListenFormRequest extends FormRequest
|
|||
'last_name' => 'required|string|between:3,100',
|
||||
'society' => 'present|nullable|string|between:3,255',
|
||||
'email' => 'required|email:rfc,strict,dns,spoof,filter|max:255',
|
||||
'phone' => [
|
||||
'present',
|
||||
'nullable',
|
||||
!is_null(request()->input('country')) ?
|
||||
(Country::make(request()->input('country'))->value === Country::france->value ?
|
||||
'phone:FR|max:25' :
|
||||
'numeric|max:50') :
|
||||
'numeric|max:50'
|
||||
],
|
||||
'postal_code' => [
|
||||
'present',
|
||||
'nullable',
|
||||
!is_null(request()->input('country')) ?
|
||||
(Country::make(request()->input('country'))->value === Country::france->value ?
|
||||
'postal_code:FR|max:25' :
|
||||
'numeric|max:50') :
|
||||
'numeric|max:50'
|
||||
],
|
||||
'phone' => array_merge(
|
||||
['present', 'nullable'],
|
||||
!is_null(request()->input('country'))
|
||||
? (Country::make(request()->input('country'))->value === Country::france->value
|
||||
? ['phone:FR', 'max:25']
|
||||
: ['numeric', 'max:50'])
|
||||
: ['numeric', 'max:50']
|
||||
),
|
||||
'postal_code' => array_merge(
|
||||
['present', 'nullable'],
|
||||
!is_null(request()->input('country'))
|
||||
? (Country::make(request()->input('country'))->value === Country::france->value
|
||||
? ['postal_code:FR', 'max:25']
|
||||
: ['numeric', 'max:50'])
|
||||
: ['numeric', 'max:50']
|
||||
),
|
||||
'city' => 'present|nullable|string|between:3,20',
|
||||
'country' => ['present', 'nullable', new Enum(Country::class)],
|
||||
'address' => 'present|nullable|string|between:3,255',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue