Skip to content
Giuseppe Cannella edited this page Jan 6, 2019 · 10 revisions
Type Name example
Email abc@def.com
EmailSimple a@b.c
assert(regexp[Email] == """^[a-zA-Z0-9\.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$""")
assert(isValid[Email]("sdsdsd@sdf.com") == true)
assert(isValid[Email]("   sdsdsd@sdf.com") == false)
assert(isValid[Email]("abc,a@%.d") == false)
assert(isValid[EmailSimple]("abc,a@%.d") == true)

using a custom pattern:

import com.github.gekomad.regexlibrary.Email
implicit val validator = Validator[Email](""".+@.+\..+""")
assert(isValid[Email]("abc,a@%.d") == true)
Clone this wiki locally