<@U2YSEPDV1> ``` data class TextyColor(val redTex...
# announcements
c
@pawel.barszcz
Copy code
data class TextyColor(val redText: String, val greenText: String, val blueText: String) {
    init {
        redText.validateColor("red")
        greenText.validateColor("green")
        blueText.validateColor("blue")
    }
}

private fun String.validateColor(name: String) = toIntOrNull()?.takeIf { it in 0..255 } ?: throw IllegalArgumentException("Invalid $name component: $this")