A simple, lightweight and powerful field validation library for Android.

Last update: May 19, 2022

Convalida

API CircleCI Build Status codecov Maven Central Android Arsenal Android Weekly

Logo

Convalida - (Italian for "validation")

Convalida is a simple, lightweight and powerful field validation library for Android.

Documentation

Go to the website for more information.

Download

To use Convalida with annotations or Data Binding support, and compile-time code generation:

dependencies {
  implementation 'io.github.wellingtoncosta:convalida-runtime:3.2.0'
  annotationProcessor 'io.github.wellingtoncosta:convalida-compiler:3.2.0'
}

If you are using Kotlin, replace annotationProcessor with kapt.

Or if you want to use only the Convalida Kotlin Dsl:

dependencies {
  implementation 'io.github.wellingtoncosta:convalida-ktx:3.2.0'
}

Snapshots of the development version are available in Sonatype's snapshots repository.

License

Copyright 2017 Wellington Costa

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

GitHub

https://github.com/wellingtoncosta/convalida
Comments
  • 1. Build issues on api 27

    First the project compiles with the following dependencies.

    compile 'com.github.WellingtonCosta:convalida:1.3.4'
    annotationProcessor 'com.github.WellingtonCosta.convalida:convalida-compiler:1.3.4'
    

    Second of all, when I try to run the project I get the errors:

    Error:java.lang.IllegalAccessException: no such method: convalida.compiler.ConvalidaProcessor.lambda$parseValidateOnClick$0(Element)boolean/invokeStatic
    Error:java.lang.NoClassDefFoundError: com/sun/tools/javac/tree/JCTree$Visitor
    Error:java.lang.ClassNotFoundException: Class com.sun.tools.javac.tree.JCTree$Visitor not found
    
    Reviewed by emanuelet at 2018-03-14 18:00
  • 2. validation on fragment is not working after back pressed

    I am using kotlin DSL for validation. I have multiple fragments opening after one another for user input. Each fragment has validation using code:

    Sample code

    private val validations by lazy {
    	validationSet(
    		validations = listOf(
    			binding.txtSomething.isRequired(errorMessage = getString(R.string.field_required))
    		),
    		actions = actions
    				validateByClickingOn binding.btnNext
    				whenOnSuccess ::onValidationSuccess
    	)
    }
    

    If I press the back button in between, validation stops working.

    Observations:

    1. apply { validations } gets called once again once user comes back on fragment
    2. validateByClickingOn binding.btnNext whenOnSuccess ::onValidationSucces does not get called second time
    Reviewed by ParitoshVaidya at 2019-10-27 10:22
  • 3. Publish sources of your artifacts to jitpack

    When I click "Download sources" while looking through your library code Android Studio says sources cannot be found. It'd be very helpful if they were.

    Reviewed by Kaned1as at 2017-11-19 19:57
  • 4. CPF validation

    Hello @WellingtonCosta,

    Does your library support CPF(Brazil personal number) validation? If not, it would be awesome to have this available in your library.

    Thanks,

    Reviewed by PriscyllaT at 2018-04-24 17:08
  • 5. Not require validation when field is blank

    Hey @WellingtonCosta ,

    You could enhance you validations making them to validate fields, but not require the validation when field is blank, for example validate an e-mail but let users save the field if it is blank.

    Reviewed by PriscyllaT at 2018-05-10 14:08
  • 6. Bump to SDK 27 and Gradle 4.4

    on my project (target api 27 and latest dependencies version) I wasn't able to get the annotations to be compiled by my app. I updated the dependencies in the project and I now can import them.

    When I build though I'm getting the following errors:

    Error:java.lang.IllegalAccessException: no such method: convalida.compiler.ConvalidaProcessor.lambda$parseValidateOnClick$0(Element)boolean/invokeStatic
    Error:java.lang.NoClassDefFoundError: com/sun/tools/javac/tree/JCTree$Visitor
    Error:java.lang.ClassNotFoundException: Class com.sun.tools.javac.tree.JCTree$Visitor not found
    
    Reviewed by emanuelet at 2018-03-14 17:39
  • 7. Add ability to validate input fields after they are unfocused

    Just my 5 cents. Users actually don't want words "Invalid email!" come screaming at them when they just typed 1 letter.

    It would be great if there'd be a way to support validate-on-unfocus pattern.

    Reviewed by Kaned1as at 2017-11-19 19:59
  • 8. Support to apply validations using a Kotlin DSL

    This feature will able Convalida to apply the validations using a Kotlin DSL that will be must defined. This will generate an artifact called convalida-ktx.

    Maybe this will turn possible to use Convalida with Anko #23.

    Reviewed by wellingtoncosta at 2018-11-07 14:50
  • 9. Validate difference between fields

    Hello @WellingtonCosta, Another improvement could be the validation of difference between two fields. Ex.: difference = incial distance - final distance, where incial distance can not be bigger than final distance.

    Regards,

    Reviewed by PriscyllaT at 2018-04-24 19:22
  • 10. Eliminate reflection code in the search for generated classes

    This issue aims to eliminate the reflection code to find and instantiate the generated classes.

    Currently, when the Convalida.init(this) is called, internally the library uses reflection to find and instantiate the generated classes for fields validation. It's not a good practice in Android.

    After this implementation, probably the Convalida.init(this) will no longer be necessary.

    Reviewed by wellingtoncosta at 2018-01-25 20:31
  • 11. Add ability to unregister validation set

    clearValidations() just clears errors on text inputs, but if user adds/removes any letter the error appears again, which is not always wanted behaviour.

    There should be way to fully unregister validation set so text input won't trigger any error on edit.

    Reviewed by Kaned1as at 2017-11-19 20:14
  • 12. Kotlin compiler Null Pointer exception

    I got the following compile error when I tried to update to the version 3.2.0 of the library.

    I don't use data-binding and I tried with both version 1.3.41 and 1.3.50 of the kotlin plugin. I tried also to set android.databinding.enableV2=false in gradle.properties to no avail

    [kapt] An exception occurred: java.lang.NullPointerException
    	at convalida.compiler.ProcessingOptions.isDatabindingEnabled(ProcessingOptions.java:34)
    	at convalida.compiler.util.JavaFiler.cookJava(JavaFiler.java:104)
    	at convalida.compiler.ConvalidaProcessor.process(ConvalidaProcessor.java:184)
    	at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt)
    	at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:147)
    	at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
    	at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
    	at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
    	at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
    	at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
    	at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
    	at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1068)
    	at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:79)
    	at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:35)
    	at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.runAnnotationProcessing(Kapt3Extension.kt:224)
    	at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:187)
    	at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:98)
    	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:97)
    	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:107)
    	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:82)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:557)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:82)
    	at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:107)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:548)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:177)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:165)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:55)
    	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:84)
    	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:42)
    	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:104)
    	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1558)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
    	at sun.rmi.transport.Transport$1.run(Transport.java:200)
    	at sun.rmi.transport.Transport$1.run(Transport.java:197)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    
    Reviewed by emanuelet at 2019-11-20 10:58
Compose easy forms validation library

Compose EasyForms Focus on building your form UI while the library do the heavy work for you. Features Built in support for most of the Form widgets i

Jul 18, 2022
Kotlin validation with a focus on readability
Kotlin validation with a focus on readability

kommodus Kotlin validation with a focus on readability import com.github.kommodus.constraints.* import com.github.kommodus.Validation data class Test

Dec 12, 2021
Validator - Notify type based validation for input fields.
Validator - Notify type based validation for input fields.

Validator - Notify type based validation for input fields.

Aug 12, 2022
Aug 12, 2022
Powerful Error Detector for Android
Powerful Error Detector for Android

Erratum Powerful Error Detector for Android Preview If an exception is detected, the exception activity is automatically launched. This activity also

Apr 13, 2022
A lightweight library for config and using SharedPreferences

preferences-helper SharePreferences is very popular with any project and all most all project has SharePreferences for saving data. This library will

May 8, 2021
Simple-Claim-Form - Android App for creating a simple dynamic form with MVVM architecture

Simple-Claim-Form Android App for creating a simple dynamic form with MVVM archi

Jan 1, 2022
A simple and easy to use stopwatch and timer library for android

TimeIt Now with Timer support! A simple and easy to use stopwatch and timer library for android Introduction A stopwatch can be a very important widge

Jun 19, 2022
Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platform the code is running.

Trail Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platfor

Apr 8, 2019
A simple Android utils library to write any type of data into cache files and read them later.

CacheUtilsLibrary This is a simple Android utils library to write any type of data into cache files and then read them later, using Gson to serialize

Aug 25, 2021
A small library which will save you from writing the same intent creation code again and again for the most simple tasks

Android Intents A small library which will save you from writing the same intent creation code again and again for the most simple tasks. I found myse

Nov 18, 2021
A Simple Android Library for Kenyan Counties

A Simple Android Library for Kenyan Counties

Jul 12, 2022
A simple library for validating user input in forms using annotations.
A simple library for validating user input in forms using annotations.

ValidationKomensky for Android A simple library for validating user input in forms using annotations. Features: Validate all views at once and show fe

Jul 14, 2022
A helper library to ease the most repetitive codes with simple reusable attributes.

ak-universal-android-helper A helper library to ease the most repetitive codes with simple reusable attributes. AKUAH can help you with many repetitiv

Jul 8, 2020
nestegg - Very simple Kotlin caching library
 nestegg - Very simple Kotlin caching library

nestegg - Very simple Kotlin caching library

Jun 15, 2022
DiskCache - Simple and readable disk cache for kotlin and android applications

DiskCache Simple and readable disk cache for kotlin and android applications (with journaled lru strategy) This is a simple lru disk cache, based on t

May 17, 2022
a simple cache for android and java

ASimpleCache ASimpleCache 是一个为android制定的 轻量级的 开源缓存框架。轻量到只有一个java文件(由十几个类精简而来)。 1、它可以缓存什么东西? 普通的字符串、JsonObject、JsonArray、Bitmap、Drawable、序列化的java对象,和 b

Aug 10, 2022
Create a simple and more understandable Android logs.
Create a simple and more understandable Android logs.

DebugLog Create a simple and more understandable Android logs. #Why? android.util.Log is the most usable library of the Android. But, when the app rel

Aug 7, 2022
✔️ Secure, simple key-value storage for Android
✔️ Secure, simple key-value storage for Android

Hawk 2.0 Secure, simple key-value storage for android Important Note This version has no backward compatibility with Hawk 1+ versions. If you still wa

Aug 14, 2022