Coder Social home page Coder Social logo

hnlshzx / android-validation-komensky Goto Github PK

View Code? Open in Web Editor NEW

This project forked from inmite/android-validation-komensky

0.0 3.0 0.0 735 KB

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

License: Apache License 2.0

Java 100.00%

android-validation-komensky's Introduction

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.2'

With Maven:

<dependency>
	<groupId>eu.inmite.android.lib</groupId>
	<artifactId>android-validation-komensky</artifactId>
	<version>0.9.2</version>
	<type>jar</type>
</dependency>

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;
@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;

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.

android-validation-komensky's People

Contributors

tomas-vondracek avatar davidvavra avatar tprochazka avatar tomaskypta avatar rtack avatar simekadam avatar

Watchers

James Cloos avatar Jay avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.