|
1 | 1 | android-formidable-validation
|
2 | 2 | =============================
|
3 | 3 |
|
4 |
| -Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Provides easy means to validate with dependencies. |
| 4 | +Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Provides easy means to validate with dependencies. |
| 5 | + |
| 6 | +Assigning ValueValidators and DependencyValidators to the ValidationManager is simple: |
| 7 | +``` |
| 8 | +//setup validation |
| 9 | +mValidationManager = new ValidationManager(this); |
| 10 | +
|
| 11 | +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.")); |
| 12 | +mValidationManager.add("addressLine1", new RegExpressionValueValidator(mAddressLine1EditText, "^[a-zA-Z0-9\\-'\\s]{3,}$", "please enter your address.")); |
| 13 | +mValidationManager.add("signupNewsletter"); |
| 14 | +mValidationManager.add("countrySpinner", new SpinnerRequiredValueValidator(mCountrySpinner, "please select a country.")); |
| 15 | +mValidationManager.add("emailAddress", new CheckBoxCheckedDependencyValidator(mEmailEditText, "signupNewsletter", mSignupNewsletterCheckBox, true, false, "Please enter your email address to signup to the newsletter list.")); |
| 16 | +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.")); |
| 17 | +mValidationManager.add("favouriteColour", new ColourPickerButtonValueValidator(mFavouriteColourButton, true)); |
| 18 | +mValidationManager.add("exampleSetErrorAbleButton", new ColourPickerButtonValueValidator(mExampleSetErrorAbleButton, true)); |
| 19 | +mValidationManager.add("exampleSetErrorAbleEditText", new RegExpressionValueValidator(mExampleSetErrorAbleEditText, "^[a-zA-Z0-9\\-'\\s]{3,}$", "please enter your address.")); |
| 20 | +``` |
| 21 | + |
| 22 | +And validating the form is just a matter of: |
| 23 | + |
| 24 | +``` |
| 25 | +mValidationManager.validateAllAndSetError(); |
| 26 | +``` |
| 27 | + |
| 28 | +Some example screenshots: |
| 29 | + |
| 30 | +![Example 01: ValidationManager automatically calls setError on a Button.][example01] |
| 31 | +![Example 02: ValidationManager automatically calls betterSetError on a SetErrorAbleButton.][example02] |
| 32 | +![Example 03: ValidationManager automatically calls betterSetError on a SetErrorAbleCheckBox.][example03] |
| 33 | +![Example 04: ValidationManager automatically calls setError on an EditText.][example04] |
| 34 | +![Example 05: ValidationManager automatically calls betterSetError on a SetErrorAbleSpinner.][example05] |
| 35 | +![Example 06: ValidationManager automatically calls betterSetError on a SetErrorAbleEditText.][example06] |
| 36 | +![Example 07: ValidationManager automatically calls setError on an EditText due to a validation dependent on a checked CheckBox.][example07] |
| 37 | + |
| 38 | +[example01]: https://github.com/coreform/android-formidable-validation/raw/master/doco/android-formidable-validation_example01.png "Example 01: ValidationManager automatically calls setError on a Button." |
| 39 | +[example02]: https://github.com/coreform/android-formidable-validation/raw/master/doco/android-formidable-validation_example01.png "Example 02: ValidationManager automatically calls setError on a Button." |
| 40 | +[example03]: https://github.com/coreform/android-formidable-validation/raw/master/doco/android-formidable-validation_example01.png "Example 03: ValidationManager automatically calls setError on a Button." |
| 41 | +[example04]: https://github.com/coreform/android-formidable-validation/raw/master/doco/android-formidable-validation_example01.png "Example 04: ValidationManager automatically calls setError on a Button." |
| 42 | +[example05]: https://github.com/coreform/android-formidable-validation/raw/master/doco/android-formidable-validation_example01.png "Example 05: ValidationManager automatically calls setError on a Button." |
| 43 | +[example06]: https://github.com/coreform/android-formidable-validation/raw/master/doco/android-formidable-validation_example01.png "Example 06: ValidationManager automatically calls setError on a Button." |
| 44 | +[example07]: https://github.com/coreform/android-formidable-validation/raw/master/doco/android-formidable-validation_example01.png "Example 07: ValidationManager automatically calls setError on a Button." |
0 commit comments