-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
We can collect errors in some cases, but we want to stick to vanilla Kotlin. So we should create an requireAll variant, than can handle multiple require statements, but still throw IllegalStateException as expected by KotlinX Serialization, and Ktor.
All code below should be generated, this is purely an example/proposal. The final result may look completely different.
fun requireAll(vararg validation: Pair<String, () -> Unit>) = TODO()
data class Person(val name: String, val age: Int) {
init {
requireAll(
Pair("Name must be of length between x and y") { name.length in x..y },
Pair("Age must be between i and j") { age in i..j }
)
}
}Reactions are currently unavailable