FormValidator

Additional

Language
Java
Version
0.2 (Dec 24, 2016)
Created
Aug 11, 2016
Updated
Apr 6, 2019 (Retired)
Owner
Alex Fu (alexfu)
Contributor
Alex Fu (alexfu)
1
Activity
Badge
Generate
Download
Source code

form-validator

A simple, easy to use, no frills, form validator for Android.

Usage

EmailRule emailRule = new EmailRule("Invalid email address.");

Validator validator = new Validator();
validate.setCallback(this);
validator.addRule(myEditText, emailRule); // Add rules to your EditText
validator.validate();

If you want to have multiple rules...

EmailRule emailRule = new EmailRule("Invalid email address.");
MinLengthRule minLengthRule = new MinLengthRule(5, "Must be at least 5 characters long.")

Validator validator = new Validator();
validate.setCallback(this);
validator.addRule(myEditText, emailRule, minLengthRule); // Add rules to your EditText
validator.validate();

Adding rules will also bind a TextWatcher to the given EditText and validate it on the fly.

Installation

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}

dependencies {
  compile 'com.github.alexfu:form-validator:2.0'
}

Rx

Fancy an Rx API? Take a look at form-validator-rx.