A set of annotations to use for TextView validation in Android
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea
app
gradle/wrapper
.gitignore
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

Validation

Download

A set of useful annotations to use for TextViews validation in Android projects

Logo

Field validators for Android TextViews which uses annotation to generate boilerplate code for you.

Installation

Gradle

compile 'com.dan.iftodi.validation:validation:0.9.3'

Maven

<dependency>
  <groupId>com.dan.iftodi.validation</groupId>
  <artifactId>validation</artifactId>
  <version>0.9.3</version>
  <type>pom</type>
</dependency>

Example

class ExampleActivity extends Activity {
  @EmailValidator
  EditText emailAddress;

  @StringValidator(minLength = 3,maxLength = 8)
  EditText password;

  @PatternValidator(pattern = "\\+//d{2,3}//d{5,8}",message = "Please use format +YYY XXXXXXX")
  EditText phoneNumber;

  void submit(View v) {
    if(Validator.validate(this))
        {
                //all fields are valid
        }
        else
        {
                //some fields are not valid
        }
  }

  @Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.simple_activity);
    // TODO Use fields...
  }
}