diff --git a/app/Services/ImportProcessor.php b/app/Services/ImportProcessor.php index 922fc47..4966dac 100644 --- a/app/Services/ImportProcessor.php +++ b/app/Services/ImportProcessor.php @@ -3118,9 +3118,10 @@ private function upsertAddress(int $personId, array $addrData, $mappings): array if (mb_strlen($addressLine) < 3) { return ['action' => 'skipped', 'message' => 'Invalid address value']; } - // Allow letters (incl. diacritics), numbers, and common separators - if (! preg_match('/^[\\p{L}0-9\\s\\.,\\-\\/\\#\\\'"\\(\\)&]+$/u', $addressLine)) { - return ['action' => 'skipped', 'message' => 'Invalid address value']; + // If identical address already exists anywhere, skip to avoid constraint violation + $existingAny = PersonAddress::where('address', $addressLine)->first(); + if ($existingAny && $existingAny->person_id !== $personId) { + return ['action' => 'skipped', 'message' => 'Address already exists for another person']; } // Default country SLO if not provided if (! isset($addrData['country']) || $addrData['country'] === null || $addrData['country'] === '') {