team names can't contain "lichess"
parent
974ec1d99b
commit
0cb6b4e0be
|
@ -90,8 +90,6 @@ object Form {
|
|||
|
||||
object eventName {
|
||||
|
||||
private val blockList = List("lichess", "liсhess") // it's not a 'c'.
|
||||
|
||||
def apply(minLength: Int, maxLength: Int, verifiedUser: Boolean) =
|
||||
cleanText.verifying(
|
||||
Constraints minLength minLength,
|
||||
|
@ -100,15 +98,20 @@ object Form {
|
|||
regex = """[\p{L}\p{N}-\s:.,;'\+]+""".r,
|
||||
error = "Invalid characters; only letters, numbers, and common punctuation marks are accepted."
|
||||
),
|
||||
Constraint[String] { (t: String) =>
|
||||
if (blockList.exists(t.toLowerCase.contains) && !verifiedUser)
|
||||
V.Invalid(V.ValidationError("Must not contain \"lichess\""))
|
||||
else V.Valid
|
||||
}
|
||||
mustNotContainLichess(verifiedUser)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
object mustNotContainLichess {
|
||||
private val blockList = List("lichess", "liсhess") // it's not a 'c'.
|
||||
def apply(verifiedUser: Boolean) = Constraint[String] { (t: String) =>
|
||||
if (blockList.exists(t.toLowerCase.contains) && !verifiedUser)
|
||||
V.Invalid(V.ValidationError("Must not contain \"lichess\""))
|
||||
else V.Valid
|
||||
}
|
||||
}
|
||||
|
||||
def stringIn(choices: Options[String]) =
|
||||
text.verifying(mustBeOneOf(choices.map(_._1)), hasKey(choices, _))
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import play.api.data._
|
|||
import play.api.data.Forms._
|
||||
import scala.concurrent.duration._
|
||||
|
||||
import lila.common.Form.{ cleanNonEmptyText, cleanText, numberIn }
|
||||
import lila.common.Form.{ cleanNonEmptyText, cleanText, mustNotContainLichess, numberIn }
|
||||
import lila.db.dsl._
|
||||
|
||||
final private[team] class TeamForm(
|
||||
|
@ -15,7 +15,7 @@ final private[team] class TeamForm(
|
|||
extends lila.hub.CaptchedForm {
|
||||
|
||||
private object Fields {
|
||||
val name = "name" -> cleanText(minLength = 3, maxLength = 60)
|
||||
val name = "name" -> cleanText(minLength = 3, maxLength = 60).verifying(mustNotContainLichess(false))
|
||||
val location = "location" -> optional(cleanText(minLength = 3, maxLength = 80))
|
||||
val password = "password" -> optional(cleanText(maxLength = 60))
|
||||
def passwordCheck(team: Team) = "password" -> optional(text).verifying(
|
||||
|
|
Loading…
Reference in New Issue