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
private static final String PHONE_PATTERN = "^\\([1-9]{2}\\)?([0-9]{9})$"; | |
@NotEmptyValidation(R.string.field_required) | |
@LengthValidation(min = 3, errorMessage = R.string.min_3_characters) | |
TextInputLayout nameLayout; | |
@OnlyNumberValidation(R.string.only_numbers) | |
TextInputLayout ageLayout; | |
@EmailValidation(R.string.invalid_email) |
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
private ConvalidaValidator validator; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_sample); | |
validator = Convalida.init(this); | |
} |
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
public void validateFields() { | |
boolean isValid = validator.validateFields(); | |
String message = isValid ? "Yay!" : "Something is wrong :("; | |
Snackbar.make(linearLayout, message, Snackbar.LENGTH_LONG).show(); | |
} |
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
public void clearFields() { | |
validator.clearValidations(); | |
} |
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
allprojects { | |
repositories { | |
... | |
maven { url 'https://jitpack.io' } | |
... | |
} | |
} |
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
dependencies { | |
compile 'com.github.WellingtonCosta.convalida:convalida:1.0.3' | |
annotationProcessor 'com.github.WellingtonCosta.convalida:convalida-compiler:1.0.3' | |
} |
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
android { | |
... | |
dataBinding { | |
enabled true | |
} | |
} |
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
dependencies { | |
... | |
kapt 'com.android.databinding:compiler:3.1.3' | |
} |
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
data class Contact(var name: String, var email: String, var phone: String) |
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
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:id="@+id/hello_layout" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content"> | |
<TextView | |
android:id="@+id/txt_hello" |
OlderNewer