# Toasts

### **Overview**

**EasyValidation** utilizes the power of Kotlin Extension methods and provides you a huge number of [built-in validation rules](https://wajahatkarim.gitbook.io/easyvalidation/usage/built-in-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.&#x20;

#### 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:

```kotlin
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.

| Method                               | Description                                                                                                                                                                                                                                                       |
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `validator()`                        | Returns the `Validator` object with text                                                                                                                                                                                                                          |
| `nonEmptyToast()`                    | <p>Returns <code>true</code> if the text is not empty. And returns <code>false</code> if text is empty.<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                   |
| `minLengthToast()`                   | <p>Returns <code>false</code> if the length of text is less than given minimum length.<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                    |
| `maxLengthToast()`                   | <p>Returns <code>false</code> if text length is greater than given length<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                 |
| `validEmailToast()`                  | <p>Returns <code>true</code> if text is a valid email address.<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                            |
| `validNumberToast()`                 | <p>Returns <code>true</code> if the text is any valid number<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                              |
| `greaterThanToast()`                 | <p>Returns <code>false</code> if the text is number less than the given target number<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                     |
| `greaterThanOrEqualToast()`          | <p>Returns <code>false</code> if the text is number less than or equal to the given target number<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                         |
| `lessThanToast()`                    | <p>Returns <code>false</code> if the text is number greater than the given target number<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                  |
| `lessThanOrEqaulToast()`             | <p>Returns <code>false</code> if the text is number greater than or equal to the given target number<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                      |
| `numberEqualToToast()`               | <p>Returns <code>false</code> if the text is a valid number and equal to the given target number<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                          |
| `allUperCaseToast()`                 | <p>Returns <code>false</code> if at least one or more characters are lower case<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                           |
| `allLowerCaseToast()`                | <p>Returns <code>false</code> if at least one or more characters are upper case<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                           |
| `atleastOneUperCaseToast()`          | <p>Returns <code>true</code> if at least one or more characters are upper case<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                            |
| `atleastOneLowerCaseToast()`         | <p>Returns <code>true</code> if at least one or more characters are lower case<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                            |
| `atleastOneNumberToast()`            | <p>Returns <code>true</code> if at least one or more characters are numbers<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                               |
| `startWithNumberToast()`             | <p>Returns <code>true</code> if text starts with any number<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                               |
| `startWithNonNumberToast()`          | <p>Returns <code>false</code> if text starts with any number<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                              |
| `noNumbersToast()`                   | <p>Returns <code>false</code> if the text any number or digit.<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                            |
| `onlyNumbersToast()`                 | <p>Returns <code>false</code> if text contains any alphabetic character<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                   |
| `noSpecialCharactersToast()`         | <p>Returns <code>true</code> if text contain no special characters<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                        |
| `atleastOneSpecialCharactersToast()` | <p>Returns <code>true</code> if text contain at least one special characters<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                              |
| `textEqaulToToast()`                 | <p>Returns <code>false</code> if the text is not equal to the given text<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                  |
| `textNotEqualToToast()`              | <p>Returns <code>true</code> if the text is not equal to the given text<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                   |
| `startsWithToast()`                  | <p>Returns <code>true</code> if the text starts with the given text<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                       |
| `endsWithToast()`                    | <p>Returns <code>true</code> if the text ends with the given text<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                         |
| `containsToast()`                    | <p>Returns <code>true</code> if the text contains the given text<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                          |
| `notContainsToast()`                 | <p>Returns <code>false</code> if the text contains the given text<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                         |
| `creditCardNumberToast()`            | <p>Returns <code>true</code> if the text is valid credit card number. This supports Visa, Master Card, American Express, Diners Club, Discover, and JCB.<br><br>Also displays the <code>Toast</code> message with the error.</p>                                  |
| `creditCardNumberWithSpacesToast()`  | <p>Returns <code>true</code> if the text is valid credit card number with spaces between 4 characters. This supports Visa, Master Card, American Express, Diners Club, Discover and JCB.<br><br>Also displays the <code>Toast</code> message with the error.</p>  |
| `creditCardNumberWithDashesToast()`  | <p>Returns <code>true</code> if the text is valid credit card number with dashes between 4 characters. This supports Visa, Master Card, American Express, Diners Club, Discover, and JCB.<br><br>Also displays the <code>Toast</code> message with the error.</p> |
| `validUrlToast()`                    | <p>Returns <code>true</code> if the text is a valid URL<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                                                   |
| `regexToast()`                       | <p>Returns <code>true</code> if the text matches passed <code>RegEx</code> pattern.<br><br>Also displays the <code>Toast</code> message with the error.</p>                                                                                                       |
