Android ValidationKomensky

Android library for validating user input easily

License

License

GroupId

GroupId

eu.inmite.android.lib
ArtifactId

ArtifactId

android-validation-komensky-parent
Last Version

Last Version

0.9.2
Release Date

Release Date

Type

Type

pom
Description

Description

Android ValidationKomensky
Android library for validating user input easily
Project URL

Project URL

https://github.com/inmite/android-validation-komensky/
Project Organization

Project Organization

Inmite.eu
Source Code Management

Source Code Management

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

Download android-validation-komensky-parent

How to add to project

<!-- https://jarcasting.com/artifacts/eu.inmite.android.lib/android-validation-komensky-parent/ -->
<dependency>
    <groupId>eu.inmite.android.lib</groupId>
    <artifactId>android-validation-komensky-parent</artifactId>
    <version>0.9.2</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/eu.inmite.android.lib/android-validation-komensky-parent/
implementation 'eu.inmite.android.lib:android-validation-komensky-parent:0.9.2'
// https://jarcasting.com/artifacts/eu.inmite.android.lib/android-validation-komensky-parent/
implementation ("eu.inmite.android.lib:android-validation-komensky-parent:0.9.2")
'eu.inmite.android.lib:android-validation-komensky-parent:pom:0.9.2'
<dependency org="eu.inmite.android.lib" name="android-validation-komensky-parent" rev="0.9.2">
  <artifact name="android-validation-komensky-parent" type="pom" />
</dependency>
@Grapes(
@Grab(group='eu.inmite.android.lib', module='android-validation-komensky-parent', version='0.9.2')
)
libraryDependencies += "eu.inmite.android.lib" % "android-validation-komensky-parent" % "0.9.2"
[eu.inmite.android.lib/android-validation-komensky-parent "0.9.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • library
  • demo

ValidationKomensky for Android

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

alt text

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.

eu.inmite.android.lib

Inmite s.r.o.

Versions

Version
0.9.2