Skip to content

Commit

Permalink
add Password value type, for masking in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
angryziber committed Jan 8, 2024
1 parent 94b03a3 commit 7e346c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Unreleased
* core: added common value types for Email and Phone, also StringValue base class
* core: added common value types for Email, Phone, and Password, also StringValue base class

# 1.6.3
* server: added support for SSE (Server-Side Events) to `HttpExchange`
Expand Down
6 changes: 5 additions & 1 deletion core/src/Types.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package klite
/** Base class for String-based normalized value types */
abstract class StringValue(val value: String) {
override fun toString() = value
override fun equals(other: Any?) = value == (other as? StringValue)?.value
override fun equals(other: Any?) = other != null && javaClass == other.javaClass && value == (other as StringValue).value
override fun hashCode() = value.hashCode()
}

Expand All @@ -22,3 +22,7 @@ class Phone(phone: String): StringValue(phone.replace(removeChars, "")) {
"International phone number should start with + and have at least 10 digits: $value" }
}
}

class Password(value: String): StringValue(value) {
override fun toString() = "Password<***>"
}

0 comments on commit 7e346c6

Please sign in to comment.