-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parameterised Secret and made the number of stars used not the same l…
…ength as the underlying value
- Loading branch information
1 parent
51d0b47
commit 1401b5b
Showing
3 changed files
with
42 additions
and
11 deletions.
There are no files selected for viewing
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
9 changes: 6 additions & 3 deletions
9
macros/src/main/scala/com/thaj/safe/string/interpolator/Secret.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
package com.thaj.safe.string.interpolator | ||
|
||
// No need of annotation macros | ||
final case class Secret(value: String) extends AnyVal | ||
final case class Secret[A](value: A) extends AnyVal | ||
|
||
object Secret { | ||
implicit val secretString: Safe[Secret] = | ||
(a: Secret) => List.fill(a.value.length)("*").mkString | ||
implicit def secretString[A: Safe]: Safe[Secret[A]] = | ||
Safe.instance( | ||
_ => "*" * Safe[A].hiddenLength, | ||
Safe[A].hiddenLength | ||
) | ||
} |
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