class Foo(val first: Int, val second: Int) { init { if (first !in 1..10) { throw IllegalArgumentException("first must be between 1 and 10") } if (second !in 22..33) { throw IllegalArgumentException("second must be between 22 and 33") } } // stringValue contains e.g. "1 22" constructor(stringValue: String) : this( parseFirst(stringValue), parseSecond(stringValue) ) } private fun parseFirst(stringValue: String): Int { //would do some parsing and validation here // .. return 1 } private fun parseSecond(stringValue: String): Int { //would do some parsing and validation here // .. return 22 }