Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/HelpersServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions tests/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]],
Expand All @@ -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(
[
Expand Down
Loading