ValidationKomensky


Source link: https://github.com/inmite/android-validation-komensky

ValidationKomensky for Android

A simple library for validating user input in forms using annotations.

Features:

  • Validate all views at once and show feedback to user. With one line of code.
  • Live validation - check user input as he moves between views with immediate feedback.
  • Extensible library - you can add your own validations or adapters for custom views.

How to include it in your project:

With Gradle:

compile 'eu.inmite.android.lib:android-validation-komensky:0.9.4@aar'

Manually:

  • clone the project
  • add it as library project in your IDE

How to validate

First, annotate your views like this:

@NotEmpty(messageId = R.string.validation_name) @MinLength(value = 3, messageId = R.string.validation_name_length, order = 2) private EditText mNameEditText;

Now you are ready to:

FormValidator.validate(this, new SimpleErrorPopupCallback(this));

You will receive collection of all failed validations in a callback and you can present them to the user as you want. Or simply use prepared callbacks (like SimpleErrorPopupCallback).

Live validation

To start and stop live validation, simply call:

FormValidator.startLiveValidation(this, new SimpleErrorPopupCallback(this));
 FormValidator.stopLiveValidation(this);

List of all supported validation annotations

Validations supported out of the box:

@NotEmpty(messageId = R.string.validation_name, order = 1) private EditText mNameEditText;
@MinLength(value = 1, messageId = R.string.validation_participants, order = 2) private EditText mNameEditText;
@MinValue(value = 2L, messageId = R.string.validation_name_length) private EditText mEditNumberOfParticipants;
@MinNumberValue(value = "5.5", messageId = R.string.validation_name_length) private EditText mEditPotentialOfHydrogen;
@RegExp(value = EMAIL, messageId = R.string.validation_valid_email) private EditText mEditEmail; @RegExp(value = "^[0-9]+$", messageId = R.string.validation_valid_count) private EditText mEditCount;
@DateInFuture(messageId = R.string.validation_date) private TextView mTxtDate;
@DateNoWeekend(messageId = R.string.validation_date_weekend) private TextView mTxtDate;
@Custom(value = MyVeryOwnValidator.class, messageId = R.string.validation_custom) private EditText mNameEditText;

Proguard

Should you need to use the proguard, copy these rules:

-keepattributes *Annotation* -keep class eu.inmite.android.lib.validations.form.annotations.** {
 *; 
}
 -keep class * implements eu.inmite.android.lib.validations.form.iface.ICondition -keep class * implements eu.inmite.android.lib.validations.form.iface.IValidator -keep class * implements eu.inmite.android.lib.validations.form.iface.IFieldAdapter -keepclassmembers class ** {
  @eu.inmite.android.lib.validations.form.annotations.** *; 
}
 

Why 'Komensky'?

Jan Ámos Komenský was a famous Czech educator, father of modern education methods.  Teachers tend to correct you, just like this library. You won't miss any errors in the user input.

See our other Czech personalities who help with #AndroidDev.

Resources

Akatsuki is an Android library that handles state restoration via annotations. The library automatically generates source files through JSR269 to ensure almost zero performance impact.

This library supports Floating Action Button transformation in Material Design Guideline.

This is an all-in-one script to build the Android adb tool for ARM architecture. When executed, the script will download all the necessary files and it will run a custom makefile to build the adb.

A 2D metaball loading indicator.

Mobile Broadcasting Library provides necessary API for broadcasting live video and audio content from mobile device to a media server, which supports RTSP publishing of interleaved H.264/AAC stream over TCP. Basic and Digest RTSP authentication methods are supported and used depending on capabilities of target media server. MBL was successfully tested with Nimble Streamer, Wowza Streaming Engine and Flussonic Media Server.

Video and audio encoding is performed via mobile camera API. Video is encoded in H.264, audio is encoded in AAC format. All streaming related processing is performed via MBL.

Folding tabbar menu for Android. You can easily add a nice animated tab menu to your app.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes