Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Commit aacba87

Browse files
author
John Cordeiro
committed
Fix username rule
1 parent 882755b commit aacba87

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

library/src/main/java/br/com/ilhasoft/support/validation/rule/UsernameRule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public UsernameRule(TextView view, String errorMessage) {
1717
@Override
1818
protected boolean isValid(TextView view) {
1919
String username = view.getText().toString();
20-
return username.matches("^[a-z0-9_-]{3,16}$");
20+
return username.matches("[a-zA-Z0-9-._]+");
2121
}
2222

2323
@Override

sample/src/main/res/layout/activity_main.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@
3030

3131
</android.support.design.widget.TextInputLayout>
3232

33+
<android.support.design.widget.TextInputLayout
34+
android:layout_width="match_parent"
35+
android:layout_height="wrap_content">
36+
37+
<android.support.design.widget.TextInputEditText
38+
android:id="@+id/username"
39+
android:layout_width="match_parent"
40+
android:layout_height="wrap_content"
41+
android:hint="Username"
42+
app:validateType='@{"username"}'
43+
app:validateTypeMessage="@{@string/custom_error_username}" />
44+
45+
</android.support.design.widget.TextInputLayout>
46+
3347
<android.support.design.widget.TextInputLayout
3448
android:layout_width="match_parent"
3549
android:layout_height="wrap_content">

sample/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<resources>
22
<string name="app_name">Support Validation</string>
3+
<string name="custom_error_username">Custom message: Username not valid</string>
34
<string name="custom_error_password_not_equal">Custom message: passwords are not equals!!</string>
45
<string name="custom_error_cpf">Custom message: CPF is wrong man!</string>
56
<string name="custom_error_date">Custom message: It\'s not a date!</string>

0 commit comments

Comments
 (0)