import kotlin.properties.Delegates var quantity: Int by Delegates.vetoable(1) { _, old, new -> println("$old -> $new") new >= 0 } fun main() { quantity = 4 quantity = -2 println(quantity) }