diff --git a/src/HelpersServiceProvider.php b/src/HelpersServiceProvider.php index e396f05..25f6763 100755 --- a/src/HelpersServiceProvider.php +++ b/src/HelpersServiceProvider.php @@ -69,13 +69,13 @@ 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)); 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 034ff27..f7ba351 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]], @@ -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( [