From c0af56ccc134a23ca8076dd1f78376a961b506d6 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Mon, 21 Aug 2023 19:42:26 +0200 Subject: [PATCH 1/3] Format composer.json --- composer.json | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8fc9613..dfe53b3 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,22 @@ "name": "intervention/validation", "description": "Additional validation rules for the Laravel framework", "homepage": "https://validation.intervention.io/", - "keywords": ["validation", "Validator", "laravel", "bic", "iban", "creditcard", "isbn", "ean", "gtin", "isin", "luhn", "base64", "data-url", "ulid"], + "keywords": [ + "validation", + "Validator", + "laravel", + "bic", + "iban", + "creditcard", + "isbn", + "ean", + "gtin", + "isin", + "luhn", + "base64", + "data-url", + "ulid" + ], "license": "MIT", "authors": [ { From a955b94f9224b6fd79027f9d8408cfae95709d9f Mon Sep 17 00:00:00 2001 From: Lasse Lehtinen Date: Fri, 8 Dec 2023 11:54:35 +0200 Subject: [PATCH 2/3] Added GS1 prefix check for ISBN's --- src/Rules/Isbn.php | 2 +- tests/Rules/IsbnTest.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Rules/Isbn.php b/src/Rules/Isbn.php index aca9485..7e32a06 100644 --- a/src/Rules/Isbn.php +++ b/src/Rules/Isbn.php @@ -37,7 +37,7 @@ public function passes($attribute, $value) return $this->shortChecksumMatches($value); case 13: - return parent::checksumMatches($value); // isbn-13 is a subset of ean-13 + return preg_match("/^(978|979)/", $value) && parent::checksumMatches($value); // isbn-13 is a subset of ean-13 } return false; diff --git a/tests/Rules/IsbnTest.php b/tests/Rules/IsbnTest.php index d220dad..cbb7364 100644 --- a/tests/Rules/IsbnTest.php +++ b/tests/Rules/IsbnTest.php @@ -69,6 +69,7 @@ public function dataProvider() [false, 'ABC'], [false, '978-0-306-40615-6'], [false, '99921-58-10-6'], + [false, '0123456789012'], ]; } @@ -122,6 +123,7 @@ public function dataProviderLong() [false, 'ABC'], [false, '978-0-306-40615-6'], [false, '99921-58-10-6'], + [false, '0123456789012'], ]; } -} +} \ No newline at end of file From 77b9a93dcd441ff52d6f135c669dbb64c466fbc5 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sat, 9 Dec 2023 17:39:14 +0100 Subject: [PATCH 3/3] Format code --- src/Rules/Isbn.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Rules/Isbn.php b/src/Rules/Isbn.php index 7e32a06..943f79c 100644 --- a/src/Rules/Isbn.php +++ b/src/Rules/Isbn.php @@ -36,8 +36,8 @@ public function passes($attribute, $value) case 10: return $this->shortChecksumMatches($value); - case 13: - return preg_match("/^(978|979)/", $value) && parent::checksumMatches($value); // isbn-13 is a subset of ean-13 + case 13: // isbn-13 is a subset of ean-13 + return preg_match("/^(978|979)/", $value) && parent::checksumMatches($value); } return false;