Skip to content

Instantly share code, notes, and snippets.

@dphans
Created April 11, 2018 03:13
Show Gist options
  • Save dphans/33b6cdfeaffbfce453df32bff6d6ba27 to your computer and use it in GitHub Desktop.
Save dphans/33b6cdfeaffbfce453df32bff6d6ba27 to your computer and use it in GitHub Desktop.
package com.dinophan.authapp.models
import com.dinophan.authapp.bases.BaseModel
class UserModel: BaseModel() {
var username: String = String()
var password: String = String()
override fun validates(): Boolean {
return try {
[email protected] = null
if ([email protected] < 6) {
if ([email protected]()) {
throw Exception("Username must be minimum 6 characters long!")
}
return false
}
[email protected] = null
if ([email protected] < 6) {
if ([email protected]()) {
throw Exception("Password must be minimum 6 characters long!")
}
return false
}
[email protected] = null
true
} catch (validationException: Exception) {
[email protected] = validationException.localizedMessage
false
}
}
fun validates(confirmationPassword: String?): Boolean {
return try {
if (confirmationPassword != null && [email protected] != confirmationPassword) {
throw Exception("Confirmation password does not match!")
}
[email protected] = null
[email protected]()
} catch (validationException: Exception) {
[email protected] = validationException.localizedMessage
false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment