Skip to content

Commit 3b4442e

Browse files
committed
Fix shipping_place name validation with vat
1 parent 444163e commit 3b4442e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/Rules/ShippingPlaceValidation.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private function address(Closure $fail): void
8484
{
8585
$validator = Validator::make($this->data, [
8686
'shipping_place' => ['nullable', 'array', new ShippingAddressRequired()],
87-
'shipping_place.name' => ['string', 'max:255', new FullName()],
87+
'shipping_place.name' => ['string', 'max:255'],
8888
'shipping_place.phone' => ['string', 'max:20'],
8989
'shipping_place.address' => ['string', 'max:255'],
9090
'shipping_place.zip' => ['string', 'max:16'],
@@ -93,6 +93,10 @@ private function address(Closure $fail): void
9393
'shipping_place.vat' => ['nullable', 'string', 'max:15'],
9494
]);
9595

96+
$validator->sometimes('shipping_place.name', [new FullName()], function ($input) {
97+
return !isset($input->shipping_place['vat']) || $input->shipping_place['vat'] === null;
98+
});
99+
96100
if ($validator->fails()) {
97101
foreach ($validator->errors()->messages() as $attribute => $messages) {
98102
foreach ($messages as $message) {

0 commit comments

Comments
 (0)