The Android Arsenal – Validation

This project gives a simple and streamlined way to validate TextInputLayoutEditText

Installation

  1. Insert the JitPack repository to your develop file
 allprojects 
  repositories 
   ...
   maven  url 'https://jitpack.io' 
  
 
  1. Incorporate the dependency
    dependencies 
         implementation 'com.github.BrianHardyR:TextInputLayoutValidator:1.1.2'
 

How to

Simple Validation

val myinput = findViewById<TextInputLayout>(R.id.my_enter)

myinput.validate(
    default = "my default text",
    validators = listOf(
         text -> t.isNotEmpty() ,
        ...
    ),
    error = "my error textual content",
    onValid =  validText -> 
        // do one thing with the legitimate text
     
)

Employing the Validation Item

Error information for each individual validation affliction
val phoneNumberValidator = TextInputValidator(
    defaultString = "My default text",
    validators = listOf(
         textual content -> (textual content.duration > 12) to "Length have to be greater than 12",
         text -> text.startsWith('+') to "Input will have to begin with '+'",
        ...
    )
)
Solitary error message
val phoneNumberValidator = TextInputValidationObj(
    default = "My default textual content",
    mistake = "Remember to enter a legitimate cellphone selection",
    validators = listOf(
         text -> text.duration > 12,
         text -> text.startsWith('+'),
        ...
    )
)

myinput.validate(phoneNumberValidator) validText ->
    // do a thing with the legitimate textual content

Validate enter After location the validation object on the TextInputLayout you can validate it anyplace on your code

myinput.legitimate() // Return a Boolean.

Next Post

Kim Kardashian Reportedly Took $1M For Keynote Speech

Pop society icon Kim Kardashian has reportedly been compensated $1 million to keynote a Miami-centered hedge fund celebration. Resources shut to the celebration have confirmed that Kardashian, who is greatly identified for her truth Tv collection and social media existence, experienced been approached to converse at the function, which is […]
Kim Kardashian Reportedly Took M For Keynote Speech

You May Like