ahegazy
08/21/2018, 1:03 PMisValidUsername
or isValidEmail
, do you feel it’s okay to write this as an extension method to String?louiscad
08/21/2018, 1:07 PMobject DataValidation {
suspend fun String.isValidUsername() = ...
suspend fun String.isValidEmail() = ...
}
with(DataValidation) {
someInputUserNameString.isValidUsername()
}
suspend
modifier is optional. I added because I assume you're checking into some database that no one has taken the username yet, and same for emailAlbert
08/21/2018, 1:11 PMDenis A
08/21/2018, 1:12 PMahegazy
08/21/2018, 1:14 PMwith
with extension methods 🙂louiscad
08/21/2018, 1:15 PMsuspend fun
example, if you ever do some db check or alike (that is, not listening to @Albert wise words) that can suspend, be sure to not let this be your only consistency check, or you're opening your system to race conditions otherwisePaul Woitaschek
08/21/2018, 3:58 PM