Created
April 11, 2018 03:13
-
-
Save dphans/33b6cdfeaffbfce453df32bff6d6ba27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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