Skip to content

Commit 6c6bd16

Browse files
feat(tags): allow to translate tags validation attributes
1 parent a5728ea commit 6c6bd16

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

extensions/tags/src/Listener/SaveTagsToDatabase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,16 @@ protected function validateTagCount($type, $count)
134134
$max = $this->settings->get('flarum-tags.max_'.$type.'_tags');
135135
$key = 'tag_count_'.$type;
136136

137+
/** @var \Illuminate\Validation\Validator $validator */
137138
$validator = $this->validator->make(
138139
[$key => $count],
139140
[$key => ['numeric', $min === $max ? "size:$min" : "between:$min,$max"]]
140141
);
141142

143+
$validator->setAttributeNames([
144+
$key => $this->translator->trans("flarum-tags.validation.attributes.$key"),
145+
]);
146+
142147
if ($validator->fails()) {
143148
throw new ValidationException([], ['tags' => $validator->getMessageBag()->first($key)]);
144149
}

0 commit comments

Comments
 (0)