-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: list_exists rules #169
Conversation
src/HelpersServiceProvider.php
Outdated
return false; | ||
} | ||
|
||
$table = Arr::get($parameters, 0); | ||
$keyField = Arr::get($parameters, 1, 'id'); | ||
|
||
if (!empty(Arr::get($parameters, 2))) { | ||
$tableFields = DB::getSchemaBuilder()->getColumnListing($table); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not good, to get table data inside the validation rule, let's keep this case without user readable error
src/HelpersServiceProvider.php
Outdated
} | ||
} | ||
|
||
if ($isExistsParam) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's rename this var to hasFieldNameParam
src/HelpersServiceProvider.php
Outdated
if (count($parameters) < 1) { | ||
$validator->errors()->add($attribute, 'You must add at least 1 parameter'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've checked it one more time and it's not good to fail validation in case the developer use validation rule incorrectly. Let's implement the separate InvalidValidationRuleUsageException
for such cases
result: [[ 'aggregate' => count($result) ]], | ||
bindings: [1, 2, 3], | ||
); | ||
DB::shouldReceive('table') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reasons to mock DB facade instead of asserting SQL?
@@ -3,6 +3,7 @@ | |||
namespace RonasIT\Support\Tests\Support\Traits; | |||
|
|||
use Illuminate\Support\Carbon; | |||
use Illuminate\Support\Facades\DB; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Illuminate\Support\Facades\DB; |
#77 (comment)