Merge branch 'contact-validation' into 'develop'

fix: 🐛 add array merge in listenFormRequest to have correct validation

See merge request ldc-web/projets/volena!47
This commit is contained in:
karl.muller 2025-09-04 13:54:08 +00:00
commit 4f02895ac8

View file

@ -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',