Created
April 13, 2018 00:33
-
-
Save nishantkp/5ca57d124396e993087948d12b0d8bb3 to your computer and use it in GitHub Desktop.
Validate user-email and password before performing login operation
This file contains hidden or 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
/** | |
* Validate user email and password | |
* Email and password EditText fields are wrapped inside TextInputLayout | |
* | |
* @return true if email and password are valid, otherwise false | |
*/ | |
private boolean isCredentialsValid() { | |
String emailAddress = edtEmail.getText().toString().trim(); | |
String password = edtPassword.getText().toString(); | |
if (TextUtils.isEmpty(emailAddress) | |
|| !android.util.Patterns.EMAIL_ADDRESS.matcher(emailAddress).matches()) { | |
edtEmailWrapper.setError("Enter valid email!"); | |
return false; | |
} else if (TextUtils.isEmpty(password)) { | |
edtPasswordWrapper.setError("Enter password"); | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment