dave08
01/30/2025, 2:38 PMclass IntRangeDecoder() : Decoder<IntRange> {
override fun supports(type: KType): Boolean = type.classifier == IntRange::class
override fun decode(node: Node, type: KType, context: DecoderContext): ConfigResult<IntRange> = when(node) {
is StringNode -> runCatching {
node.value.split("..").let { IntRange(it[0].toInt(), it[1].toInt()) }
}.toValidated { ConfigFailure.DecodeError(node, type) }
else -> ConfigFailure.DecodeError(node, type).invalid()
}
}