Skip to content

Commit

Permalink
Format with scalafmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoknjas committed Nov 24, 2024
1 parent b33c0b3 commit 8a42259
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions modules/common/src/main/Form.scala
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,16 @@ object Form:
addLengthConstraints(cleanTextWithSymbols, minLength, maxLength)

def cleanFewSymbolsText(
minLength: Int = 0, maxLength: Int = Int.MaxValue, maxSymbols: Int = 0
minLength: Int = 0,
maxLength: Int = Int.MaxValue,
maxSymbols: Int = 0
): Mapping[String] =
cleanTextWithSymbols(minLength, maxLength).verifying(fewSymbolsConstraint(maxSymbols))

def cleanFewSymbolsAndNonEmptyText(
minLength: Int = 0, maxLength: Int = Int.MaxValue, maxSymbols: Int = 0
minLength: Int = 0,
maxLength: Int = Int.MaxValue,
maxSymbols: Int = 0
): Mapping[String] =
cleanFewSymbolsText(minLength, maxLength, maxSymbols).verifying(nonEmptyOrSpace)

Expand All @@ -119,9 +123,11 @@ object Form:
raw"[\p{So}\p{block=Emoticons}\p{block=Miscellaneous Symbols and Pictographs}\p{block=Supplemental Symbols and Pictographs}]".r

def fewSymbolsConstraint(maxSymbols: Int): V.Constraint[String] = V.Constraint[String] { t =>
if symbolsRegex.findAllMatchIn(t).size > maxSymbols then V.Invalid(
V.ValidationError(s"Must not contain more than $maxSymbols emojis or other symbols")
) else V.Valid
if symbolsRegex.findAllMatchIn(t).size > maxSymbols then
V.Invalid(
V.ValidationError(s"Must not contain more than $maxSymbols emojis or other symbols")
)
else V.Valid
}

val slugConstraint: V.Constraint[String] =
Expand Down

0 comments on commit 8a42259

Please sign in to comment.