title: Kotlin - how to validate data class
body: <p>I have a class:</p>
  
  <pre><code>class Foo{
    var x:Long = 10
      set(value) {if( value &lt; 0 ) throw IllegalArgumentException("error"); field=value}
  }
  </code></pre>
  
  <p>Is it possible to validate these values in a more elegant way? For example - I want something like this:</p>
  
  <pre><code>class Foo( @Positive var x: Long) {
  }
  </code></pre>
  
  <p>Is it possible? I want it to be lightweight - no reflections, just check on settler. Any suggestions? </p>