From 6b1505fbf4dd6260d8ab123bcfdb86bd15b5cd96 Mon Sep 17 00:00:00 2001 From: eparusov Date: Thu, 26 Dec 2024 11:22:22 +0300 Subject: [PATCH 1/2] refactor: message --- src/HelpersServiceProvider.php | 2 +- tests/ValidatorTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HelpersServiceProvider.php b/src/HelpersServiceProvider.php index e396f05a..1910f91f 100755 --- a/src/HelpersServiceProvider.php +++ b/src/HelpersServiceProvider.php @@ -69,7 +69,7 @@ protected function extendValidator(): void Validator::extend('list_exists', function ($attribute, $value, $parameters, $validator) { if (count($parameters) < 1) { - throw new InvalidValidationRuleUsageException('You must add at least 1 parameter.'); + throw new InvalidValidationRuleUsageException("list_exists: At least 1 parameter must be added when checking the {$attribute} field in the request."); } $hasFieldNameParam = !empty(Arr::get($parameters, 2)); diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php index 034ff27c..65032d18 100644 --- a/tests/ValidatorTest.php +++ b/tests/ValidatorTest.php @@ -136,7 +136,7 @@ public function testListExistsFailedValidation() public function testListExistsWithoutArgs() { $this->expectException(InvalidValidationRuleUsageException::class); - $this->expectExceptionMessage('You must add at least 1 parameter.'); + $this->expectExceptionMessage('list_exists: At least 1 parameter must be added when checking the ids field in the request.'); $validator = Validator::make( ['ids' => [1, 2, 3]], From 1d354470a739042d69f8251d5e213417245ac115 Mon Sep 17 00:00:00 2001 From: eparusov Date: Thu, 26 Dec 2024 16:23:14 +0300 Subject: [PATCH 2/2] refactor: message --- src/HelpersServiceProvider.php | 2 +- tests/ValidatorTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HelpersServiceProvider.php b/src/HelpersServiceProvider.php index 1910f91f..25f6763b 100755 --- a/src/HelpersServiceProvider.php +++ b/src/HelpersServiceProvider.php @@ -75,7 +75,7 @@ protected function extendValidator(): void $hasFieldNameParam = !empty(Arr::get($parameters, 2)); if (is_multidimensional($value) && !$hasFieldNameParam) { - throw new InvalidValidationRuleUsageException('The third argument should be filled for collections input.'); + throw new InvalidValidationRuleUsageException("list_exists: The third parameter should be filled when checking the {$attribute} field if we are using a collection in request."); } if ($hasFieldNameParam) { diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php index 65032d18..f7ba3518 100644 --- a/tests/ValidatorTest.php +++ b/tests/ValidatorTest.php @@ -149,7 +149,7 @@ public function testListExistsWithoutArgs() public function testListExistsIncorrectParameters() { $this->expectException(InvalidValidationRuleUsageException::class); - $this->expectExceptionMessage('The third argument should be filled for collections input.'); + $this->expectExceptionMessage('The third parameter should be filled when checking the ids field if we are using a collection in request.'); $validator = Validator::make( [