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
LoginValidation - A simple login app with password validation

LoginValidation A simple login app with password validation License Copyright 20

Srihitha Tadiparthi 2 Feb 18, 2022
XCore is a Open-Source , simple and lightweight API & Template for Android Apps.

XCore XCore is a Open-Source , simple and lightweight API & Template for Android Apps. Support XCore is compatible with Android Studio & Sketchware Pr

TherionRO 3 Dec 2, 2022
Restler is a beautiful and powerful Android app for quickly testing REST API anywhere and anytime.

Restler Restler has been built with simplicity and ease of use in mind. It allows you send custom HTTP/HTTPS requests and test your REST API anywhere

Tiago 10 Dec 20, 2022
A simple, lightweight, non-bloated redis client for kotlin and other JVM languages

rekt is a lightweight, non-bloated redis client, primarily written for the kotlin programming language, while also supporting other JVM-based languages, such as Java, Scala, and obviously way more.

Patrick 8 Nov 2, 2022
A stable and very powerful Kotlin bot.

Nabi 나비 Yeah idk what to put here anymore stfu azoo bloo Also chat commands are not being considered so no I don't recommend that you build the entire

myosyn 2 Oct 5, 2022
A lightweight library for requesting and consuming Activity Results using coroutines.

SuspendActivityResult A lightweight library for requesting and consuming Activity Results using coroutines, it's usage is as simple as: val uri = Acti

Hicham Boushaba 71 Dec 23, 2022
A lightweight Kotlin library which converts images to PixelArt in Android.

PixelArtImageView PixelArtImageView is a lightweight library used to convert standalone images into pixel art. The view extends ImageView behaviour an

Josh Owen 2 May 15, 2022
Kotools Assert is a lightweight assertions library for Kotlin

Kotools Assert is a lightweight assertions library for Kotlin

Kotools 1 Nov 3, 2022
Depenject - a lightweight, minimalistic dependency injection library for Kotlin/JVM.

depenject depenject is a lightweight, minimalistic dependency injection library for Kotlin/JVM. Our goal is similar to flavor's to simplify the usage

Patrick 1 Mar 22, 2022
A lightweight tool for managing and building Kotlin projects.

kpm kpm (Kotlin Project Manager) is a lightweight tool for managing and building Kotlin projects. What is kpm? Essentially, kpm is going to be a light

Conor Byrne 5 Apr 23, 2022
A lightweight Trakt API.

This library is a lightweight Trakt API. It supports Swift, Kotlin, and JavaScript by setting up as a Kotlin Multiplatform project.

Moviebase 6 Nov 1, 2022
A pragmatic lightweight dependency injection framework for Kotlin developers.

A pragmatic lightweight dependency injection framework for Kotlin developers. Koin is a DSL, a light container and a pragmatic API

insert-koin.io 11 Dec 14, 2022
☁️ cloud.sh is a lightweight self-hosted cloud for your home lab.

DISCLAIMER: cloud.sh is under development. We do not recommend you to use it in a production environment for now. The storage could be corrupted when

Quentin Guidée 13 Nov 24, 2022
A Simple Android library to get the number of words and give you the time it will take you to finish an article/story.

MinRead A Simple Android library to get the number of words and give you the time it will take you to finish an article/story. Prerequisite Androidx K

Nwokocha wisdom maduabuchi 36 Nov 17, 2021
Simple event library to communicate between Activity/Fragment and ViewModel

Setup dependencies { implementation "com.github.skgmn:viewmodelevent:1.1.0" } If you don't know how to access to GitHub Packges, please refer to

null 4 Apr 6, 2022
🌨️ Simple, intuitive, and opinionated command handling library for Kord

??️ Snow Simple, intuitive, and opinionated command handling library for Kord Why? Since I maintain two Discord bots, both in Kotlin, Nino and Noel (p

Noel ʕ •ᴥ•ʔ 1 Jan 16, 2022
🔥The Android Startup library provides a straightforward, performant way to initialize components at the application startup. Both library developers and app developers can use Android Startup to streamline startup sequences and explicitly set the order of initialization.

??The Android Startup library provides a straightforward, performant way to initialize components at the application startup. Both library developers and app developers can use Android Startup to streamline startup sequences and explicitly set the order of initialization.

Rouse 1.3k Dec 30, 2022
Web Container: A simple web container library for Android to help fellow developer to open WebView easily

WebContainer Description Web Container is a simple web container library for And

Achmad Ichsan Thaib 8 Nov 22, 2022
MiStoryView is a simple configurable library to integrate stories features into your social media android application.

MiStoryView MiStoryView is a simple configurable library to integrate stories features into your social media android application. Preview Key feature

MindInventory 35 Dec 22, 2022