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

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

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

object Email extends Validator[String] {
  // http://www.w3.org/TR/html-markup/input.email.html
  private val PATTERN = """^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$""".r

  def check(value: String) =
    PATTERN.findFirstIn(value).isDefined

  def message(name: String, value: String) =
    if (check(value))
      None
    else
      Some("%s must be an email address".format(name))
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy