aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStewart Stewart <stewinsalot@gmail.com>2017-03-30 21:05:28 -0700
committerStewart Stewart <stewinsalot@gmail.com>2017-03-30 21:05:47 -0700
commit646eeb4fbc4e285d3f9e7a1cd0c44b62234ef7b3 (patch)
tree92144a7af8b7aa2d978b3607d7383c45f035b17c
parentcb1f773aeda5e93a69cce25f1e972bc29c3cb4b1 (diff)
downloaddriver-core-646eeb4fbc4e285d3f9e7a1cd0c44b62234ef7b3.tar.gz
driver-core-646eeb4fbc4e285d3f9e7a1cd0c44b62234ef7b3.tar.bz2
driver-core-646eeb4fbc4e285d3f9e7a1cd0c44b62234ef7b3.zip
use case insensitive string comparison for emails
-rw-r--r--src/main/scala/xyz/driver/core/domain.scala12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/core/domain.scala b/src/main/scala/xyz/driver/core/domain.scala
index f2629ee..d16606b 100644
--- a/src/main/scala/xyz/driver/core/domain.scala
+++ b/src/main/scala/xyz/driver/core/domain.scala
@@ -1,12 +1,24 @@
package xyz.driver.core
+import scalaz.Equal
+import scalaz.syntax.equal._
+import scalaz.std.string._
+
object domain {
final case class Email(username: String, domain: String) {
+ override def equals(other: Any) = other match {
+ case Email(otherUser, otherDomain) =>
+ username.toLowerCase === otherUser.toLowerCase && domain.toLowerCase === otherDomain.toLowerCase
+ case _ => false
+ }
+
override def toString = username + "@" + domain
}
object Email {
+ implicit val emailEqual: Equal[Int] = Equal.equalA[Int]
+
def parse(emailString: String): Option[Email] = {
Some(emailString.split("@")) collect {
case Array(username, domain) => Email(username, domain)