Skip to content

Commit a02141c

Browse files
committed
adding extension for checking if charsequence is a matrix id
1 parent 38763d0 commit a02141c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

vector/src/main/java/im/vector/app/core/extensions/BasicExtensions.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package im.vector.app.core.extensions
1919
import android.util.Patterns
2020
import com.google.i18n.phonenumbers.NumberParseException
2121
import com.google.i18n.phonenumbers.PhoneNumberUtil
22+
import org.matrix.android.sdk.api.MatrixPatterns
2223
import org.matrix.android.sdk.api.extensions.ensurePrefix
2324

2425
fun Boolean.toOnOff() = if (this) "ON" else "OFF"
@@ -30,6 +31,8 @@ inline fun <T> T.ooi(block: (T) -> Unit): T = also(block)
3031
*/
3132
fun CharSequence.isEmail() = Patterns.EMAIL_ADDRESS.matcher(this).matches()
3233

34+
fun CharSequence.isMatrixId() = MatrixPatterns.isUserId(this.toString())
35+
3336
/**
3437
* Return empty CharSequence if the CharSequence is null.
3538
*/

0 commit comments

Comments
 (0)