Skip to content

Commit

Permalink
fix: timer description
Browse files Browse the repository at this point in the history
  • Loading branch information
y9vad9 committed Jan 3, 2024
1 parent a7af1cd commit 3f3bc64
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import io.timemates.backend.users.types.value.UserId
data class Timer(
val id: TimerId,
val name: TimerName,
val description: TimerDescription,
val description: TimerDescription?,
val ownerId: UserId,
val settings: TimerSettings,
val membersCount: Count,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.timemates.backend.timers.types.value

import io.timemates.backend.validation.FailureMessage
import io.timemates.backend.validation.SafeConstructor
import io.timemates.backend.validation.ValidationFailureHandler
import io.timemates.backend.validation.reflection.wrapperTypeName
Expand All @@ -9,7 +8,7 @@ import io.timemates.backend.validation.reflection.wrapperTypeName
value class TimerDescription private constructor(val string: String) {
companion object : SafeConstructor<TimerDescription, String>() {
override val displayName: String by wrapperTypeName()
private val LENGTH_RANGE = 3..200
private val LENGTH_RANGE = 0..200

context(ValidationFailureHandler)
override fun create(value: String): TimerDescription {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class TimersMapper(private val sessionMapper: TimerSessionMapper) : Mapper {
return Timer(
id = TimerId.createOrThrowInternally(dbTimer.id),
name = TimerName.createOrThrowInternally(dbTimer.name),
description = TimerDescription.createOrThrowInternally(dbTimer.description),
description = dbTimer.description.takeUnless { it.isBlank() }
?.let { TimerDescription.createOrThrowInternally(it) },
ownerId = UserId.createOrThrowInternally(dbTimer.ownerId),
settings = dbSettingsToDomainSettings(dbTimer.settings),
membersCount = Count.createOrThrowInternally(membersCount),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal fun TimerSettings.rs(): Timer.Settings {
internal fun CoreTimer.rs(): Timer {
return Timer.create {
name = this@rs.name.string
description = this@rs.description.string
description = this@rs.description?.string.orEmpty()
ownerId = this@rs.ownerId.long
settings = this@rs.settings.rs()
membersCount = this@rs.membersCount.int
Expand Down

0 comments on commit 3f3bc64

Please sign in to comment.