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

Overview

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.
Comments
  • Build issues on api 27

    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
    
    opened by emanuelet 18
  • validation on fragment is not working after back pressed

    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
    opened by ParitoshVaidya 9
  • Publish sources of your artifacts to jitpack

    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.

    opened by Kaned1as 4
  • CPF validation

    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,

    enhancement 
    opened by PriscyllaT 3
  • Not require validation when field is blank

    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.

    enhancement 
    opened by PriscyllaT 2
  • Bump to SDK 27 and Gradle 4.4

    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
    
    opened by emanuelet 2
  • Add ability to validate input fields after they are unfocused

    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.

    opened by Kaned1as 2
  • Support to apply validations using a Kotlin DSL

    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.

    enhancement 
    opened by wellingtoncosta 1
  • Validate difference between fields

    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,

    enhancement 
    opened by PriscyllaT 1
  • Eliminate reflection code in the search for generated classes

    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.

    enhancement 
    opened by wellingtoncosta 1
  • Add ability to unregister validation set

    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.

    opened by Kaned1as 1
  • Kotlin compiler Null Pointer exception

    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)
    
    bug 
    opened by emanuelet 1
Releases(3.2.0)
Owner
Wellington Costa
Don't give up.
Wellington Costa
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

Kosh Sergani 24 Jul 18, 2022
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

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

Validator - Notify type based validation for input fields.

Mustafa Yiğit 57 Dec 8, 2022
Sample project displaying process of OTP validation using firebase

OTP-Validation-using-firebase Sample project displaying process of OTP validation using firebase Screenshots Concepts used Integrated Firebase sdk for

Ankita Gaba 2 Jun 18, 2022
Simple Mobile Tools 172 Dec 26, 2022
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

Ji Sungbin 5 Dec 3, 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

Khang Tran 23 May 8, 2021
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

Yashovardhan Dhanania 35 Dec 10, 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

Mauricio Togneri 13 Aug 29, 2022
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

Shubham Gangpuri 1 Aug 14, 2022
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

Wesley Lin 134 Nov 25, 2022
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

MarvinLabs 420 Nov 20, 2022
A Simple Android Library for Kenyan Counties

A Simple Android Library for Kenyan Counties

Joel Kanyi 18 Jul 12, 2022
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

Inmite s.r.o. 512 Nov 20, 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

Aakash Kumar 20 Jul 8, 2020
nestegg - Very simple Kotlin caching library

nestegg - Very simple Kotlin caching library

Runner-be 4 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

Giovanni Corte 14 Dec 2, 2022
a simple cache for android and java

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

Michael Yang 3.7k Dec 14, 2022
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

mf 418 Nov 25, 2022