Adds an isValid function to all commands so we can check before sending

This commit is contained in:
Vitor Pamplona
2025-10-10 11:33:18 -04:00
parent fa971b1822
commit 0c0410d1dd
6 changed files with 12 additions and 0 deletions

View File

@@ -27,6 +27,8 @@ class AuthCmd(
) : Command {
override fun label(): String = LABEL
override fun isValid() = true
companion object {
const val LABEL = "AUTH"
}

View File

@@ -25,6 +25,8 @@ class CloseCmd(
) : Command {
override fun label(): String = LABEL
override fun isValid() = subId.isNotEmpty()
companion object {
const val LABEL = "CLOSE"
}

View File

@@ -24,4 +24,6 @@ import com.vitorpamplona.quartz.nip01Core.core.OptimizedSerializable
interface Command : OptimizedSerializable {
fun label(): String
fun isValid(): Boolean
}

View File

@@ -28,6 +28,8 @@ class CountCmd(
) : Command {
override fun label(): String = LABEL
override fun isValid() = subId.isNotEmpty() && filters.isNotEmpty()
companion object {
const val LABEL = "COUNT"
}

View File

@@ -27,6 +27,8 @@ class EventCmd(
) : Command {
override fun label(): String = LABEL
override fun isValid() = true
companion object {
const val LABEL = "EVENT"
}

View File

@@ -28,6 +28,8 @@ class ReqCmd(
) : Command {
override fun label(): String = LABEL
override fun isValid() = subId.isNotEmpty() && filters.isNotEmpty()
companion object {
const val LABEL = "REQ"
}