Toasts

This section describes how to use Kotlin extension methods for validation checks, which displays errors in the Toast messages.

Overview

EasyValidation utilizes the power of Kotlin Extension methods and provides you a huge number of built-in validation rules in the form of extensions on String, EditText, TextView, AutoCompleteTextView, TextInputLayout, and Spinner classes.

This page explains about a Toasts module, which is the part of EasyValidation and automatically displays all the validation errors in the Toast message by default.

Installation

Add this in your app-level build.gradle file.

implementation "com.wajahatkarim:easyvalidation-toast:$ev_version"

And now you can use the extention methods with are like **Toast() on String, EditText, TextView, AutoCompleteTextView, TextInputLayout, and Spinner classes.

For example, you can check some validation checks on EditText like this:

var txtEmail = findViewById<EditText>(R.id.txtEmail)

// Valid email check
txtName.validEmailToast() { msg ->
    // Invalid email
    txtName.error = msg
}

// Minimum length check
txtName.minLengthToast(5) {
    txtName.error = it
}

List of Extension Methods

Here is the list of all extension methods for String, EditText, TextView, AutoCompleteTextView, TextInputLayout, and Spinner classes.

Last updated