Is there some best practice for how to do field validation in data classes?
currently I'm doing it in the init-block and that seems to work, is this the best way or am I missing something? (other suggestions welcome as well
Copy code
data class Username(val name:String) {
init {
if (name.isEmpty()) {
throw IllegalArgumentException("Username can't be empty")
}
}
}