android-formidable-validation
Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Provides easy means to validate with dependencies.
Assigning ValueValidators and DependencyValidators to the ValidationManager is simple:
//setup validation
mValidationManager = new ValidationManager(this);
mValidationManager.add("understood", new CheckBoxRequiredValueValidator(mUnderstoodCheckBox, "You must acknowledge that this form does not submit data anywhere and that it is simply for demonstration purposes."));
mValidationManager.add("addressLine1", new RegExpressionValueValidator(mAddressLine1EditText, "^[a-zA-Z0-9\\-'\\s]{3,}$", "please enter your address."));
mValidationManager.add("signupNewsletter");
mValidationManager.add("countrySpinner", new SpinnerRequiredValueValidator(mCountrySpinner, "please select a country."));
mValidationManager.add("emailAddress", new CheckBoxCheckedDependencyValidator(mEmailEditText, "signupNewsletter", mSignupNewsletterCheckBox, true, false, "Please enter your email address to signup to the newsletter list."));
mValidationManager.add("emailAddress", new RegExpressionValueValidator(mEmailEditText, "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$", "Email address must be valid."));
mValidationManager.add("favouriteColour", new ColourPickerButtonValueValidator(mFavouriteColourButton, true));
mValidationManager.add("exampleSetErrorAbleButton", new ColourPickerButtonValueValidator(mExampleSetErrorAbleButton, true));
mValidationManager.add("exampleSetErrorAbleEditText", new RegExpressionValueValidator(mExampleSetErrorAbleEditText, "^[a-zA-Z0-9\\-'\\s]{3,}$", "please enter your address."));
And validating the form is just a matter of:
mValidationManager.validateAllAndSetError();