Closed sunxyw closed 2 years ago
Hi @sunxyw, thank you for reporting this issue.
I believe I've managed to reproduce this in #72, so will work on a fix when I get a little time. If you have any suggestions towards a fix, feel free to message over on the PR 😄
(cc: @tomirons)
This error still presents even updated to the latest version v1.12.1.
Weird, I thought the test case would have caught this. I’ll take a look at this when I get back home in a few hours.
cc: @tomirons
I tried fixing it myself, maybe it wasn't the best way, but it did get rid of the error.
if (is_array($rules)) {
foreach ($rules as $i => $rule) {
if (is_object($rule)) {
unset($rules[$i]);
}
}
$this->validator = Validator::make([], [$attribute => implode('|', $rules)]);
Hi @sunxyw,
I'll be taking a look at this today, I had a bit of a busy day yesterday so didn't get round to it.
Thanks for posting your solution. I'll need to be able to reproduce this through a unit test before I can submit a fix though.
Do you have any ideas how we could maybe reproduce it in a unit test?
Okay, I managed to reproduce it. It's when a rule class is within an array of rules.
Good, please take your time, this is not in a hurry.
This has now been resolved in the latest release. Thanks again for your help on the issue.
Environment:
When executing
php artisan export:postman
withenable_formdata = true
it throws an error:It works well when
enable_formdata = false
.Here is my request and rule:
Does this package not yet support custom rules? Or am I doing something wrong?