Skip to content

Instantly share code, notes, and snippets.

@ivportilla
Created May 24, 2017 18:13
Show Gist options
  • Save ivportilla/713187809513830f530a15ab005a73af to your computer and use it in GitHub Desktop.
Save ivportilla/713187809513830f530a15ab005a73af to your computer and use it in GitHub Desktop.
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