The easiest way to bring validation to your project

Overview

RxValidationTextInputLayout

The easiest way to bring validation to EditText with TextInputLayout.

Getting Started

Add dependency to your project using JitPack

allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
dependencies {
		implementation 'com.github.KucherenkoIhor:RxValidationTextInputLayout:0.2.2'
}

Using in XML:

     <com.kucherenko.RxValidationTextInputLayout
                android:id="@+id/tilFirstName"
                style="@style/TextInputLayout.Counter"
                android:layout_marginTop="@dimen/margin_l"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="parent"
                app:help="at least 3 letters"
                app:error="@string/invalid_first_name"
                app:errorTextAppearance="@style/TextAppearance.AppCompat.Small.Error"
                app:helperTextAppearance="@style/TextAppearance.AppCompat.Small.Helper"
                app:regex="@string/regex_name">
    
                <android.support.design.widget.TextInputEditText
                    android:id="@+id/etFirstName"
                    style="@style/EditText.SingleLine"
                    android:hint="@string/hint_first_name"
                    android:imeOptions="actionNext"
                    android:inputType="textPersonName" />
    
            </com.kucherenko.RxValidationTextInputLayout>

And get simple boolean result using RxJava2 in Java code:

 tilFirstName.onReady = { observable ->  
            disposable = observable.subscribe { isValid ->
                btnSignIn.isEnabled = isValid
            }
        }

Features

  • Reactive approach using RxJava2:
tilFirstName.onReady = { observable ->
            disposable = observable.subscribe { isValid ->
                btnSignIn.isEnabled = isValid
            }
        }
  • Or if you want to observe several fields:
val textInputLayouts = arrayOf(
                tilFirstName,
                tilLastName,
                tilEmail,
                tilPhone,
                tilYear,
                tilDob,
                tilPassword,
                tilConfirmPassword)

        RxValidationTextInputLayout.combineOnReady(*textInputLayouts) { observable ->
            disposable = observable
                   .debounce { Observable.timer(if (it) 500L else 0L, TimeUnit.MILLISECONDS) }
                   .subscribe { btnSignIn.isEnabled = it }
        }

  • Simple regex support: app:regex="@string/regex_name"
  • You can change configuration as you need:
    • You can allow empty state of input field: app:allowEmpty="true"
    • Or disable error showing when filed is empty app:showErrorIfEmpty="true"
  • Compare input with another one app:equalEditText="@id/etPassword". It's useful for password and confirm password fields:

  • Helper text according to Material Design Guidelines

    app:help="Must be the same with password"

  • Error text appears if input text lose focus: app:error="@string/invalid_password"

  • Custom text styles for help and error states: app:errorTextAppearance="@style/TextAppearance.AppCompat.Small.Error" app:helperTextAppearance="@style/TextAppearance.AppCompat.Small.Helper"

Changelog

Version: 0.2.1

  • Improved equal edit text functionality

Version: 0.1.3

  • Fixed onReady issues

Version: 0.1.2

  • Added the methods to trigger error text immediately

Licenses

MIT

You might also like...
:closed_umbrella: An easy way to implement modern permission instructions popup.
:closed_umbrella: An easy way to implement modern permission instructions popup.

Needs An easy way to implement modern permission instructions popup. Needs can be fully customized and showing with animations. Download Gradle Add be

:performing_arts: An easy, flexible way to implement veil skeletons and shimmering effect for Android.
:performing_arts: An easy, flexible way to implement veil skeletons and shimmering effect for Android.

AndroidVeil An easy, flexible way to implement veil skeletons and shimmering effect for Android. Download Gradle Add below codes to your root build.gr

A fragment binding library - the easier, efficient way.

Byda allprojects { repositories { ... maven { url 'https://jitpack.io' } } } dependencies { implementation 'com.github.Codzure:B

Extension functions over Android's callback-based APIs which allows writing them in a sequential way within coroutines or observe multiple callbacks through kotlin flow.

callback-ktx A lightweight Android library that wraps Android's callback-based APIs into suspending extension functions which allow writing them in a

Modern Calendar View Supporting Both Hijri and Gregorian Calendars but in highly dynamic way
Modern Calendar View Supporting Both Hijri and Gregorian Calendars but in highly dynamic way

KCalendar-View Modern calendar view supporting both Hijri and Gregorian calendar

kinstall is an easy way to install gradle-based command-line kotlin projects that use the application plugin.

kinstall kinstall is an easy way to install gradle-based command-line kotlin projects that use the application plugin. use First, install kinstall its

AdsManager - Easy way to implement Google Ads

AdsManager Easy way to implement Google Ads Implementaion: https://jitpack.io/#R

Koin Annotations - help declare Koin definition in a very fast and intuitive way, and generate all underlying Koin DSL for you

The goal of Koin Annotations project is to help declare Koin definition in a very fast and intuitive way, and generate all underlying Koin DSL for you. The goal is to help developer experience to scale and go fast 🚀 , thanks to Kotlin Compilers.

 A Kotlin library providing a simple, high-performance way to use off-heap native memory in JVM applications.
A Kotlin library providing a simple, high-performance way to use off-heap native memory in JVM applications.

native_memory_allocator A library which uses sun.misc.Unsafe to allocate off-heap native memory. Motivation The goal of this project is to provide a s

Releases(0.2.2)
Owner
Ihor Kucherenko
Android developer
Ihor Kucherenko
Schedule-4-me is an opinionated to-do app to bring chaos to your life.

Schedule-4-me Have you ever had too much control in your life? Ever find yourself stuck at home repeating the same motions over and over again? Well f

null 4 Jan 16, 2022
Easiest routing for compose-jb

Easiest routing for compose-jb Supported targets: Jvm Js Installation repositories { mavenCentral() } dependencies { implementation("io.githu

null 31 Nov 18, 2022
AppConversorMoedas - The currency conversion using an API to bring the data up to date

LAB - Criando um app de conversor moedas/cambio com Kotlin. O curso pode ser ace

Davi Braga 0 Jan 1, 2022
Display code with syntax highlighting :sparkles: in native way.

CodeView (Android) CodeView helps to show code content with syntax highlighting in native way. Description CodeView contains 3 core parts to implement

Kirill Biakov 827 Dec 22, 2022
:bouquet: An easy way to persist and run code block only as many times as necessary on Android.

Only ?? An easy way to persist and run code block only as many times as necessary on Android. Download Gradle Add below codes to your root build.gradl

Jaewoong Eum 479 Dec 25, 2022
A simple way to handle remote image in Kotlin.

Parrot A kotlin extension to load easily remote images in your ImageView. Install Add to gradle in allprojects maven { url 'https://jitpack.io' } the

Matteo Crippa 22 Oct 3, 2022
Android Library that provide simpler way to achieve modularity

ToyBricks 中文文档 ToyBricks简介以及原理分析 ToyBricks用户手册 Introduction Android Library that provide simpler way to achieve modularity. Compile System requirement

null 33 Nov 14, 2022
Simple Android Library, that provides easy way to start the Activities with arguments.

Warning: Library is not maintained anymore. If you want to take care of this library, propose it via Pull Request. It needs adjustmensts for newer ver

Marcin Moskała 429 Dec 15, 2022
:bouquet: An easy way to persist and run code block only as many times as necessary on Android.

Only ?? An easy way to persist and run code block only as many times as necessary on Android. Download Gradle Add below codes to your root build.gradl

Jaewoong Eum 468 Apr 14, 2021