From a9004da3d02ba6d972d32a3397c656acaab729e2 Mon Sep 17 00:00:00 2001 From: Marcus Olsson Date: Thu, 4 Sep 2025 11:54:22 +0200 Subject: [PATCH] Fix bad org regex --- src/Organization.php | 2 +- tests/SwedishEntityTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Organization.php b/src/Organization.php index 0660bd4..7168d50 100644 --- a/src/Organization.php +++ b/src/Organization.php @@ -71,7 +71,7 @@ public function format(bool $separator = true): string */ public function valid(): bool { - if (!preg_match("/^\d{6}[\-\/]?\d{4}+$/", $this->orgNo)) { + if (!preg_match('/^\d{6}-?\d{4}$/', $this->orgNo)) { return false; } diff --git a/tests/SwedishEntityTest.php b/tests/SwedishEntityTest.php index a69010b..4f2d4d7 100644 --- a/tests/SwedishEntityTest.php +++ b/tests/SwedishEntityTest.php @@ -133,6 +133,7 @@ public function testInvalidCompanies() $this->assertFalse((new Organization('556016-0681'))->valid()); $this->assertFalse((new Organization('556103-4250'))->valid()); $this->assertFalse((new Organization('5561034250'))->valid()); + $this->assertFalse((new Organization('556103/4250'))->valid()); } /** @test */