11/*
2- * Copyright 1998-2023 Linux.org.ru
2+ * Copyright 1998-2026 Linux.org.ru
33 * Licensed under the Apache License, Version 2.0 (the "License");
44 * you may not use this file except in compliance with the License.
55 * You may obtain a copy of the License at
@@ -18,8 +18,6 @@ package ru.org.linux.tag
1818import org .springframework .validation .Errors
1919import ru .org .linux .user .UserErrorException
2020
21- import scala .jdk .CollectionConverters .*
22-
2321object TagName {
2422 val MaxTagsPerTopic = 5
2523 private val MinTagLength = 1
@@ -71,10 +69,14 @@ object TagName {
7169 }
7270 }
7371
74- if (goodTags.size > maxTags) {
72+ if (goodTags.sizeIs > maxTags) {
7573 errors.rejectValue(" tags" , null , " Слишком много тегов (максимум " + maxTags + ')' )
7674 }
7775
76+ if (! errors.hasErrors && goodTags.isEmpty) {
77+ errors.rejectValue(" tags" , null , " Установите теги" )
78+ }
79+
7880 goodTags.toVector
7981 }
8082
@@ -84,9 +86,6 @@ object TagName {
8486 * @param tags список тегов через запятую
8587 * @return список тегов
8688 */
87- def parseAndSanitizeTagsJava (tags: String ): java.util.List [String ] =
88- parseAndSanitizeTags(tags).asJava
89-
9089 def parseAndSanitizeTags (tags : String ): Seq [String ] =
9190 parseTags(tags).filter(isGoodTag).toVector
9291}
0 commit comments