Skip to content
Giuseppe Cannella edited this page Jan 6, 2019 · 10 revisions
Type name example
Email abc@def.com
import com.github.gekomad.regexcollection.Email
assert(validate[Email]("sdsdsd@sdf.com") == Some("sdsdsd@sdf.com"))
assert(validate[Email]("   sdsdsd@sdf.com") == None)
assert(validate[Email]("abc,a@%.d") == None)
Type name example
EmailSimple a@b.c
import com.github.gekomad.regexcollection.EmailSimple
assert(validate[EmailSimple]("abc,a@%.d") == Some("abc,a@%.d"))

using a custom pattern:

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