All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xitrum.validator.MaxLength.scala Maven / Gradle / Ivy

There is a newer version: 3.28.18
Show newest version
package xitrum.validator

object MaxLength {
  def apply(length: Int) = new MaxLength(length)
}

class MaxLength(max: Int) extends Validator[String] {
  def check(value: String) = value.length <= max

  def message(name: String, value: String) =
    if (value.length <= max)
      None
    else
      Some("%s must not be longer than %d characters".format(name, max))
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy