Skip to content

Commit

Permalink
chore: fix validation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Nov 19, 2024
1 parent af8f278 commit e876da8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions extensions/tags/src/TagCountValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Flarum\Tags;

use Flarum\Foundation\AbstractValidator;
use Illuminate\Support\Arr;

class TagCountValidator extends AbstractValidator
{
Expand Down Expand Up @@ -88,12 +89,20 @@ protected function getRules()
$min = $this->min;
$max = $this->max;

return [
"tag_count_{$type}" => [
$key = "tag_count_{$type}";

$rules = [
$key => [
'numeric',
"size:{$min}",
"between:{$min},{$max}"
]
];

if ( $min === $max ) {
Arr::add($rules, $key, "size:{$min}");
} else {
Arr::add($rules, $key, "between:{$min},{$max}");
}

return $rules;
}
}

0 comments on commit e876da8

Please sign in to comment.