From 9c0432dc7e7cfb81c61bace8c9ff1f1ae53d0214 Mon Sep 17 00:00:00 2001 From: Juraj Kusnier Date: Thu, 1 Apr 2021 13:06:59 +0200 Subject: [PATCH] Update trace location attributes validation --- .../create/TraceLocationCreateViewModel.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/eventregistration/organizer/create/TraceLocationCreateViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/eventregistration/organizer/create/TraceLocationCreateViewModel.kt index ec92752306e..55a2af7908a 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/eventregistration/organizer/create/TraceLocationCreateViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/eventregistration/organizer/create/TraceLocationCreateViewModel.kt @@ -93,17 +93,15 @@ class TraceLocationCreateViewModel @AssistedInject constructor( isDateVisible = category.uiType == TraceLocationUIType.EVENT, isSendEnable = when (category.uiType) { TraceLocationUIType.LOCATION -> { - description.trim().length in 1..100 && - address.trim().length in 0..100 && + description.isTextFormattedCorrectly() && + address.isTextFormattedCorrectly() && checkInLength > Duration.ZERO && !requestInProgress } TraceLocationUIType.EVENT -> { - description.trim().length in 1..100 && - address.trim().length in 0..100 && - begin != null && - end != null && - end?.isAfter(begin) == true && + description.isTextFormattedCorrectly() && + address.isTextFormattedCorrectly() && + begin != null && end != null && end?.isAfter(begin) == true && !requestInProgress } } @@ -111,6 +109,8 @@ class TraceLocationCreateViewModel @AssistedInject constructor( ) } + private fun String.isTextFormattedCorrectly() = trim().length in 1..100 && !contains('\n') + data class UIState( private val begin: LocalDateTime? = null, private val end: LocalDateTime? = null,