mirror of
https://github.com/etesync/android
synced 2024-12-23 07:08:16 +00:00
Signup: add field validations.
We have centralised validation in the server, but it's not yet exposed in etebase-java so we have to do it here too for now.
This commit is contained in:
parent
afe7f12a9d
commit
12d25a7785
@ -79,7 +79,7 @@ class SignupFragment(private val initialUsername: String?, private val initialPa
|
||||
createAccount.setOnClickListener {
|
||||
val credentials = validateData()
|
||||
if (credentials != null) {
|
||||
SignupDoFragment(credentials).show(fragmentManager!!, null)
|
||||
SignupDoFragment(credentials).show(requireFragmentManager(), null)
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +102,8 @@ class SignupFragment(private val initialUsername: String?, private val initialPa
|
||||
var valid = true
|
||||
|
||||
val userName = editUserName.editText?.text.toString()
|
||||
if (userName.isEmpty()) {
|
||||
// FIXME: this validation should only be done in the server, we are doing it here until the Java library supports field errors
|
||||
if ((userName.length < 6) || (!userName.matches(Regex("""^[\w.-]+$""")))) {
|
||||
editUserName.error = getString(R.string.login_username_error)
|
||||
valid = false
|
||||
} else {
|
||||
@ -118,7 +119,7 @@ class SignupFragment(private val initialUsername: String?, private val initialPa
|
||||
}
|
||||
|
||||
val password = editPassword.editText?.text.toString()
|
||||
if (password.isEmpty()) {
|
||||
if (password.length < 8) {
|
||||
editPassword.error = getString(R.string.signup_password_restrictions)
|
||||
valid = false
|
||||
} else {
|
||||
|
@ -230,7 +230,7 @@
|
||||
<!-- AddAccountActivity -->
|
||||
<string name="login_title">Add account</string>
|
||||
<string name="login_username">Username</string>
|
||||
<string name="login_username_error">Valid username required</string>
|
||||
<string name="login_username_error">Username should be at least 6 characters long and consist of only letters, digits and ./-/_.</string>
|
||||
<string name="login_email_address">Email</string>
|
||||
<string name="login_email_address_error">Valid email required</string>
|
||||
<string name="login_password">Password</string>
|
||||
|
Loading…
Reference in New Issue
Block a user