From a02141c7c2e4a4a2aa059c63fc276c709ec5fd35 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 13 Jul 2022 13:23:27 +0100 Subject: [PATCH] adding extension for checking if charsequence is a matrix id --- .../main/java/im/vector/app/core/extensions/BasicExtensions.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vector/src/main/java/im/vector/app/core/extensions/BasicExtensions.kt b/vector/src/main/java/im/vector/app/core/extensions/BasicExtensions.kt index 63d61af0e6..6bcbfe0ed5 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/BasicExtensions.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/BasicExtensions.kt @@ -19,6 +19,7 @@ package im.vector.app.core.extensions import android.util.Patterns import com.google.i18n.phonenumbers.NumberParseException import com.google.i18n.phonenumbers.PhoneNumberUtil +import org.matrix.android.sdk.api.MatrixPatterns import org.matrix.android.sdk.api.extensions.ensurePrefix fun Boolean.toOnOff() = if (this) "ON" else "OFF" @@ -30,6 +31,8 @@ inline fun T.ooi(block: (T) -> Unit): T = also(block) */ fun CharSequence.isEmail() = Patterns.EMAIL_ADDRESS.matcher(this).matches() +fun CharSequence.isMatrixId() = MatrixPatterns.isUserId(this.toString()) + /** * Return empty CharSequence if the CharSequence is null. */