Andreas Sinz
09/24/2018, 8:32 PMclass Person private constructor(val name: String, val age: Int) : Individual {
//stuff
}
fun Person(name: String, age: Int): Person {
require(age >= 18)
return Person(name, age)
}Hullaballoonatic
09/24/2018, 8:34 PMAndreas Sinz
09/24/2018, 8:35 PMHullaballoonatic
09/24/2018, 8:35 PMHullaballoonatic
09/24/2018, 8:36 PMval email: Email? = Email(submittedEmailAddress)Andreas Sinz
09/24/2018, 8:37 PMPerson is via the factory method beneath itHullaballoonatic
09/24/2018, 8:40 PMHullaballoonatic
09/24/2018, 8:41 PMinvoke operator function for the factory methodAndreas Sinz
09/24/2018, 8:42 PMEmailAddress instances that contain faulty addresses? You could check the provided "ab@xy.net" when creating an instance of EmailAddressAndreas Sinz
09/24/2018, 8:42 PMinvoke() inside the companion object works tooHullaballoonatic
09/24/2018, 8:43 PMAndreas Sinz
09/24/2018, 8:43 PMPerson.copy() or directly set person.age = 14, because that bypasses the factory method and its checksHullaballoonatic
09/24/2018, 8:43 PMHullaballoonatic
09/24/2018, 8:45 PMAndreas Sinz
09/24/2018, 8:46 PMinit { } hackHullaballoonatic
09/24/2018, 8:47 PMHullaballoonatic
09/24/2018, 8:48 PMAndreas Sinz
09/24/2018, 8:49 PMinline classes would be available already 😅Hullaballoonatic
09/24/2018, 8:49 PMusername in table -> existsException
email in table -> exists ExceptionHullaballoonatic
09/24/2018, 8:50 PMtable.usernameExists(username) -> existsException
table.emailExists(email) -> existsExceptionHullaballoonatic
09/24/2018, 8:51 PMHullaballoonatic
09/24/2018, 8:52 PMAndreas Sinz
09/24/2018, 8:55 PMHullaballoonatic
09/24/2018, 9:17 PM