Michael de Kaste
05/01/2025, 8:22 AMdata class Request(
    val type: Type
	val value: String?
)
enum class Type { A, B }
data class A(val value: String)
data class B(val value: String?)
fun Request.toDto() = when(type){
    Type.A if value == null -> throw ApiValidationException("value has to be filled when type is A")
	Type.A -> A(value) // <-- Cannot infer value being non-null
    Type.B -> B(value)
}dmitriy.novozhilov
05/05/2025, 6:51 AMType.A if value == nullType.A