An easy-to-use text field validator for Kotlin & Jetpack compose.

Overview

kotlin-version

validable

Validating text fields when using jetpack compose can sometimes be challenging and verbose.

Validable is an extensible library that allows you to validate your text fields in a simpler way while having a reusable code.

This is what it looks like :

Welcome screen

@Composable  
fun MyScreen() { 
 
     val emailField = remember { EmailValidable() }  
     
	TextField(  
	    value = emailField.value,
	    onValueChange = { emailField.value = it }, // update the text  
	    isError = emailField.hasError(), // check if the field is not valid    
	)  
  
	AnimatedVisibility(visible = emailField.hasError()) {
	
	    Text(
                text = emailField.errorMessage ?: "",
            	modifier = Modifier.fillMaxWidth(),
            	style = LocalTextStyle.current.copy(color = MaterialTheme.colors.error)
	    )
        
	}  
	
	Button(onClick = {  
	    // pass all fields to the withValidable method 
	    withValidable(emailField) {  
		 
		// will be executed if all fields are valid 		
		Toast.makeText(context,"All fields are valid",Toast.LENGTH_SHORT).show() 
		
		} 
	}) { 
		Text(text = "Submit") 
	}  
}  

Installation

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency

dependencies {
    implementation 'com.github.devscast:validable:x.y.z'
}

The latest version of this library is

For full documentation, check out the wiki page

Contributing

We'd love contributions !

We will also try to tag any issues on our issue tracker that we'd love help with, so if you just want to dip in, go have a look.

If you do want to contribute to this project, we have a code of conduct.

You might also like...
ComposeTextBug - Issue with MotionLayout+Compose in Text functionality

ComposeTextBug Issue with MotionLayout+Compose in Text functionality Demo: devic

ComposeChips - A gmail like chip edit text for compose ui

ComposeChips A gmail like chip edit text for compose ui Installation implementat

Easy zoom in with drag support for Jetpack Compose
Easy zoom in with drag support for Jetpack Compose

ComposeZoomableImage Jetpack Compose Zoomable Image Android Library Easy zoom in with drag support for Jetpack Compose Demo Setup Add Jitpack maven {

Jetpack Compose Boids | Flocking Insect ๐Ÿœ. bird or Fish simulation using Jetpack Compose Desktop ๐Ÿš€, using Canvas API ๐ŸŽจ
Jetpack Compose Boids | Flocking Insect ๐Ÿœ. bird or Fish simulation using Jetpack Compose Desktop ๐Ÿš€, using Canvas API ๐ŸŽจ

๐Ÿœ ๐Ÿœ ๐Ÿœ Compose flocking Ants(boids) ๐Ÿœ ๐Ÿœ ๐Ÿœ Jetpack compose Boids | Flocking Insect. bird or Fish simulation using Jetpack Compose Desktop ๐Ÿš€ , usi

A collection of animations, compositions, UIs using Jetpack Compose. You can say Jetpack Compose cookbook or play-ground if you want!
A collection of animations, compositions, UIs using Jetpack Compose. You can say Jetpack Compose cookbook or play-ground if you want!

Why Not Compose! A collection of animations, compositions, UIs using Jetpack Compose. You can say Jetpack Compose cookbook or play-ground if you want!

This is a sample app(For beginners - App #2) built using Jetpack Compose. It demonstrates the concept of State Hoisting in Jetpack Compose.
This is a sample app(For beginners - App #2) built using Jetpack Compose. It demonstrates the concept of State Hoisting in Jetpack Compose.

JetBMICalculator This is a sample app(For beginners - App #2) built using Jetpack Compose. It demonstrates the concept of State Hoisting in Jetpack Co

Jetpack-Compose-Demo - Instagram Profile UI using Jetpack Compose
Jetpack-Compose-Demo - Instagram Profile UI using Jetpack Compose

Jetpack-Compose-Demo Instagram Profile UI using Jetpack Compose

Jetpack-compose-animations-examples - Cool animations implemented with Jetpack compose
Jetpack-compose-animations-examples - Cool animations implemented with Jetpack compose

Jetpack-compose-animations-examples This repository consists of 4 animations: St

Compose-navigation - Set of utils to help with integrating Jetpack Compose and Jetpack's Navigation

Jetpack Compose Navigation Set of utils to help with integrating Jetpack Compose

Releases(1.2.0)
Owner
Devscast
The boost you need
Devscast
Field state manager and basic set of validation, fields

Compose Forms Field state manager and basic set of validation, fields

Vitaliy Zarubin 9 Jan 4, 2022
๐Ÿ—ป Unopinionated, easy-to-use, and customizable Badge component for Jetpack Compose

Cobadge ?? Unopinionated, easy-to-use, and customizable Badge component for Jetpack Compose Getting started In this section I will walk you through th

Michael Grigoryan 5 Jun 28, 2022
An easy to use action/overflow menu for Jetpack Compose.

Compose Action Menu This library provides an easy-to-use action menu for Compose, since Compose doesn't offer this by default. Features Icons (optiona

Jacob Ras 36 Nov 24, 2022
Learn Jetpack Compose for Android by Examples. Learn how to use Jetpack Compose for Android App Development. Androidโ€™s modern toolkit for building native UI.

Learn Jetpack Compose for Android by Examples. Learn how to use Jetpack Compose for Android App Development. Androidโ€™s modern toolkit for building native UI.

MindOrks 382 Jan 5, 2023
A simple tool to display a text tree with Jetpack Compose๐ŸŒฒ

A simple tool to display a text tree with Jetpack Compose??

Takahiro Menju 50 Oct 5, 2022
Drawing text around other content in Jetpack Compose

TextAroundContent Drawing text around other content in Jetpack Compose Installat

Dmitry Mysenko 8 Feb 9, 2022
A Jetpack Compose component used for displaying Markdown-formatted text.

MarkdownText A library for displaying Markdown contents within Jetpack Compose. Uses Coil Current limitations Lists that are annotated with the * must

Arnau Mora 4 Dec 15, 2022
A Kotlin library to use Jetpack Compose in Android and iOS. Allow to write UI for both in Kotin. Still experimental as many compose features are not yet available.

Multiplatform Compose A Kotlin library to use Jetpack Compose in Android and iOS. Allow to write UI for both in Kotin. Still experimental as many comp

Clรฉment Beffa 548 Jan 7, 2023
A simple authentication application using Jetpack compose to illustrate signin and sign up using Mvvm, Kotlin and jetpack compose

Authentication A simple authentication application using Jetpack compose to illustrate signin and sign up using Mvvm, Kotlin and jetpack compose Scree

Felix Kariuki 5 Dec 29, 2022
A particle view library written in kotlin, easy to use

particle ไธญๆ–‡ไป‹็ป This is a handy android library for particle effect. To start with, you need to add it in your root build.gradle at the end of repositor

null 89 Nov 14, 2022