Skip to content

Commit e876da8

Browse files
chore: fix validation logic
1 parent af8f278 commit e876da8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

extensions/tags/src/TagCountValidator.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Flarum\Tags;
1111

1212
use Flarum\Foundation\AbstractValidator;
13+
use Illuminate\Support\Arr;
1314

1415
class TagCountValidator extends AbstractValidator
1516
{
@@ -88,12 +89,20 @@ protected function getRules()
8889
$min = $this->min;
8990
$max = $this->max;
9091

91-
return [
92-
"tag_count_{$type}" => [
92+
$key = "tag_count_{$type}";
93+
94+
$rules = [
95+
$key => [
9396
'numeric',
94-
"size:{$min}",
95-
"between:{$min},{$max}"
9697
]
9798
];
99+
100+
if ( $min === $max ) {
101+
Arr::add($rules, $key, "size:{$min}");
102+
} else {
103+
Arr::add($rules, $key, "between:{$min},{$max}");
104+
}
105+
106+
return $rules;
98107
}
99108
}

0 commit comments

Comments
 (0)