Merge pull request #6428 from ornicar/fix-streamer-form

Update streamer form for Twitch URLs and names with 25 chars
This commit is contained in:
Thibault Duplessis 2020-04-20 13:37:28 -06:00 committed by GitHub
commit f577e39ba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -176,7 +176,7 @@ object edit extends Context.ToLang {
form3.group(
form("name"),
streamerName(),
help = keepItShort(20).some,
help = keepItShort(25).some,
half = true
)(form3.input(_)),
form3.checkbox(

View file

@ -80,8 +80,8 @@ object Streamer {
def minUrl = s"twitch.tv/$userId"
}
object Twitch {
private val UserIdRegex = """([\w-]{2,24}+)""".r
private val UrlRegex = """twitch\.tv/([\w-]{2,24}+)""".r.unanchored
private val UserIdRegex = """([\w-]{2,25}+)""".r
private val UrlRegex = """twitch\.tv/([\w-]{2,25}+)""".r.unanchored
// https://www.twitch.tv/chessnetwork
def parseUserId(str: String): Option[String] = str match {
case UserIdRegex(u) => u.some

View file

@ -20,7 +20,7 @@ object StreamerForm {
text
.verifying(
Constraints.minLength(2),
Constraints.maxLength(24)
Constraints.maxLength(47)
)
.verifying("Invalid Twitch username", s => Streamer.Twitch.parseUserId(s).isDefined)
),
@ -111,6 +111,6 @@ object StreamerForm {
implicit private val nameFormat = formatter.stringFormatter[Name](_.value, Name.apply)
private def nameField = of[Name].verifying(
constraint.minLength[Name](_.value)(3),
constraint.maxLength[Name](_.value)(20)
constraint.maxLength[Name](_.value)(25)
)
}