Do check only on Debug
This commit is contained in:
@@ -22,12 +22,8 @@ import java.io.Serializable
|
||||
@JvmInline
|
||||
value class EventId(val value: String) : Serializable
|
||||
|
||||
fun String.asEventId() = if (MatrixPatterns.isEventId(this)) {
|
||||
EventId(this)
|
||||
fun String.asEventId() = if (BuildConfig.DEBUG && !MatrixPatterns.isEventId(this)) {
|
||||
error("`$this` is not a valid event Id")
|
||||
} else {
|
||||
if (BuildConfig.DEBUG) {
|
||||
error("`$this` is not a valid event Id")
|
||||
} else {
|
||||
null
|
||||
}
|
||||
EventId(this)
|
||||
}
|
||||
|
||||
@@ -22,12 +22,8 @@ import java.io.Serializable
|
||||
@JvmInline
|
||||
value class RoomId(val value: String) : Serializable
|
||||
|
||||
fun String.asRoomId() = if (MatrixPatterns.isRoomId(this)) {
|
||||
RoomId(this)
|
||||
fun String.asRoomId() = if (BuildConfig.DEBUG && !MatrixPatterns.isRoomId(this)) {
|
||||
error("`$this` is not a valid room Id")
|
||||
} else {
|
||||
if (BuildConfig.DEBUG) {
|
||||
error("`$this` is not a valid room Id")
|
||||
} else {
|
||||
null
|
||||
}
|
||||
RoomId(this)
|
||||
}
|
||||
|
||||
@@ -20,12 +20,8 @@ import io.element.android.libraries.matrix.api.BuildConfig
|
||||
|
||||
typealias SessionId = UserId
|
||||
|
||||
fun String.asSessionId() = if (MatrixPatterns.isSessionId(this)) {
|
||||
SessionId(this)
|
||||
fun String.asSessionId() = if (BuildConfig.DEBUG && !MatrixPatterns.isSessionId(this)) {
|
||||
error("`$this` is not a valid session Id")
|
||||
} else {
|
||||
if (BuildConfig.DEBUG) {
|
||||
error("`$this` is not a valid session Id")
|
||||
} else {
|
||||
null
|
||||
}
|
||||
SessionId(this)
|
||||
}
|
||||
|
||||
@@ -27,12 +27,8 @@ value class SpaceId(val value: String) : Serializable
|
||||
*/
|
||||
val MAIN_SPACE = SpaceId("!mainSpace")
|
||||
|
||||
fun String.asSpaceId() = if (MatrixPatterns.isSpaceId(this)) {
|
||||
SpaceId(this)
|
||||
fun String.asSpaceId() = if (BuildConfig.DEBUG && !MatrixPatterns.isSpaceId(this)) {
|
||||
error("`$this` is not a valid space Id")
|
||||
} else {
|
||||
if (BuildConfig.DEBUG) {
|
||||
error("`$this` is not a valid space Id")
|
||||
} else {
|
||||
null
|
||||
}
|
||||
SpaceId(this)
|
||||
}
|
||||
|
||||
@@ -22,12 +22,8 @@ import java.io.Serializable
|
||||
@JvmInline
|
||||
value class ThreadId(val value: String) : Serializable
|
||||
|
||||
fun String.asThreadId() = if (MatrixPatterns.isThreadId(this)) {
|
||||
ThreadId(this)
|
||||
fun String.asThreadId() = if (BuildConfig.DEBUG && !MatrixPatterns.isThreadId(this)) {
|
||||
error("`$this` is not a valid thread Id")
|
||||
} else {
|
||||
if (BuildConfig.DEBUG) {
|
||||
error("`$this` is not a valid thread Id")
|
||||
} else {
|
||||
null
|
||||
}
|
||||
ThreadId(this)
|
||||
}
|
||||
|
||||
@@ -22,12 +22,8 @@ import java.io.Serializable
|
||||
@JvmInline
|
||||
value class UserId(val value: String) : Serializable
|
||||
|
||||
fun String.asUserId() = if (MatrixPatterns.isUserId(this)) {
|
||||
UserId(this)
|
||||
fun String.asUserId() = if (BuildConfig.DEBUG && !MatrixPatterns.isUserId(this)) {
|
||||
error("`$this` is not a valid user Id")
|
||||
} else {
|
||||
if (BuildConfig.DEBUG) {
|
||||
error("`$this` is not a valid user Id")
|
||||
} else {
|
||||
null
|
||||
}
|
||||
UserId(this)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user