softwaremill / stringmask

A micro-library for macro-based case class field masking in .toString

GitHub

stringmask

Maven Central License Build Status

A micro-library for macro-based case class field masking in .toString(). Inspired by blog by Juan Pedro Moreno @47deg: http://www.47deg.com/blog/scala-macros-annotate-your-case-classes

Using stringmask

Builds are available for Scala 2.11 and 2.12

libraryDependencies ++= Seq(
  "com.softwaremill.stringmask" %% "stringmask" % "1.3.0",
  compilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)
)

Example usage:

import com.softwaremill.macros.customize.{customize, mask}
import java.util.Date

@customize
case class User(id: Long, @mask email: String, @mask dob: Date)
val user = User(1, "johndoe@email.com", new Date(1458732695220L))

user.toString

should return User(1,***,***)