Do check only on Debug
This commit is contained in:
parent
1f7b897216
commit
798629faf7
6 changed files with 18 additions and 42 deletions
|
|
@ -22,12 +22,8 @@ import java.io.Serializable
|
||||||
@JvmInline
|
@JvmInline
|
||||||
value class EventId(val value: String) : Serializable
|
value class EventId(val value: String) : Serializable
|
||||||
|
|
||||||
fun String.asEventId() = if (MatrixPatterns.isEventId(this)) {
|
fun String.asEventId() = if (BuildConfig.DEBUG && !MatrixPatterns.isEventId(this)) {
|
||||||
EventId(this)
|
error("`$this` is not a valid event Id")
|
||||||
} else {
|
} else {
|
||||||
if (BuildConfig.DEBUG) {
|
EventId(this)
|
||||||
error("`$this` is not a valid event Id")
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,8 @@ import java.io.Serializable
|
||||||
@JvmInline
|
@JvmInline
|
||||||
value class RoomId(val value: String) : Serializable
|
value class RoomId(val value: String) : Serializable
|
||||||
|
|
||||||
fun String.asRoomId() = if (MatrixPatterns.isRoomId(this)) {
|
fun String.asRoomId() = if (BuildConfig.DEBUG && !MatrixPatterns.isRoomId(this)) {
|
||||||
RoomId(this)
|
error("`$this` is not a valid room Id")
|
||||||
} else {
|
} else {
|
||||||
if (BuildConfig.DEBUG) {
|
RoomId(this)
|
||||||
error("`$this` is not a valid room Id")
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,8 @@ import io.element.android.libraries.matrix.api.BuildConfig
|
||||||
|
|
||||||
typealias SessionId = UserId
|
typealias SessionId = UserId
|
||||||
|
|
||||||
fun String.asSessionId() = if (MatrixPatterns.isSessionId(this)) {
|
fun String.asSessionId() = if (BuildConfig.DEBUG && !MatrixPatterns.isSessionId(this)) {
|
||||||
SessionId(this)
|
error("`$this` is not a valid session Id")
|
||||||
} else {
|
} else {
|
||||||
if (BuildConfig.DEBUG) {
|
SessionId(this)
|
||||||
error("`$this` is not a valid session Id")
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,8 @@ value class SpaceId(val value: String) : Serializable
|
||||||
*/
|
*/
|
||||||
val MAIN_SPACE = SpaceId("!mainSpace")
|
val MAIN_SPACE = SpaceId("!mainSpace")
|
||||||
|
|
||||||
fun String.asSpaceId() = if (MatrixPatterns.isSpaceId(this)) {
|
fun String.asSpaceId() = if (BuildConfig.DEBUG && !MatrixPatterns.isSpaceId(this)) {
|
||||||
SpaceId(this)
|
error("`$this` is not a valid space Id")
|
||||||
} else {
|
} else {
|
||||||
if (BuildConfig.DEBUG) {
|
SpaceId(this)
|
||||||
error("`$this` is not a valid space Id")
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,8 @@ import java.io.Serializable
|
||||||
@JvmInline
|
@JvmInline
|
||||||
value class ThreadId(val value: String) : Serializable
|
value class ThreadId(val value: String) : Serializable
|
||||||
|
|
||||||
fun String.asThreadId() = if (MatrixPatterns.isThreadId(this)) {
|
fun String.asThreadId() = if (BuildConfig.DEBUG && !MatrixPatterns.isThreadId(this)) {
|
||||||
ThreadId(this)
|
error("`$this` is not a valid thread Id")
|
||||||
} else {
|
} else {
|
||||||
if (BuildConfig.DEBUG) {
|
ThreadId(this)
|
||||||
error("`$this` is not a valid thread Id")
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,8 @@ import java.io.Serializable
|
||||||
@JvmInline
|
@JvmInline
|
||||||
value class UserId(val value: String) : Serializable
|
value class UserId(val value: String) : Serializable
|
||||||
|
|
||||||
fun String.asUserId() = if (MatrixPatterns.isUserId(this)) {
|
fun String.asUserId() = if (BuildConfig.DEBUG && !MatrixPatterns.isUserId(this)) {
|
||||||
UserId(this)
|
error("`$this` is not a valid user Id")
|
||||||
} else {
|
} else {
|
||||||
if (BuildConfig.DEBUG) {
|
UserId(this)
|
||||||
error("`$this` is not a valid user Id")
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue