Created
May 24, 2017 18:13
-
-
Save ivportilla/713187809513830f530a15ab005a73af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Dni(src: String, parsed: String) { | |
override def equals(obj: scala.Any): Boolean = obj match { | |
case dni: Dni => dni.src == src || dni.parsed == parsed | |
case dni: String => dni == src || dni == parsed | |
case _ => false | |
} | |
override def toString: String = src | |
} | |
object Dni { | |
private def parseDni(nit: String): String = | |
nit.replaceAll("[a-zA-Z\\s-]", "") | |
def apply(src: String): Dni = Dni(src, parseDni(src)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment