Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wajahatkarim3/easyvalidation
:heavy_check_mark: A text and input validation library in Kotlin for Android
https://github.com/wajahatkarim3/easyvalidation
android android-library kotlin kotlin-android kotlin-android-extensions kotlin-extensions kotlin-library library validation validation-library
Last synced: 2 days ago
JSON representation
:heavy_check_mark: A text and input validation library in Kotlin for Android
- Host: GitHub
- URL: https://github.com/wajahatkarim3/easyvalidation
- Owner: wajahatkarim3
- License: apache-2.0
- Created: 2018-04-30T12:54:53.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-13T15:54:33.000Z (almost 3 years ago)
- Last Synced: 2025-01-12T01:09:41.434Z (9 days ago)
- Topics: android, android-library, kotlin, kotlin-android, kotlin-android-extensions, kotlin-extensions, kotlin-library, library, validation, validation-library
- Language: Kotlin
- Homepage:
- Size: 1.06 MB
- Stars: 396
- Watchers: 5
- Forks: 64
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
The article on how this library was created is now published. You can read it on this link here. →.![](https://raw.githubusercontent.com/wajahatkarim3/EasyValidation/master/Art/easyvalidlogo.jpg)
## ✔️ Changelog
Changes exist in the [releases](https://github.com/wajahatkarim3/EasyValidation/releases) tab.## 💻 Installation
Add this in app's ```build.gradle``` file:```groovy
def ev_version = "1.0.4"
implementation "com.wajahatkarim:easyvalidation-core:$ev_version"// Shows Toasts by default for every validation error
implementation "com.wajahatkarim:easyvalidation-toast:$ev_version"
```## 📄 Documentation
Full documentation is available at [Gitbook](https://wajahatkarim.gitbook.io/easyvalidation/).## ⭐️ Features
* The Validator way validation support. - [Details](https://wajahatkarim.gitbook.io/easyvalidation/usage/untitled)
* 30+ built-in validation rules like empty, email, credit cards, etc. - [Rules List](https://wajahatkarim.gitbook.io/easyvalidation/usage/built-in-rules)
* Extension methods for `String`, `EditText`, `TextView`, `AutoCompleteTextView`, `TextInputLayout`, and `Spinner`. - [Details](https://wajahatkarim.gitbook.io/easyvalidation/usage/validation-using-extension-methods)
* Multiple Validations and Checks - [Details](https://wajahatkarim.gitbook.io/easyvalidation/usage/multiple-validation-checks)
* Collection Extension Methods for validations on multiple texts and views - [Details](https://wajahatkarim.gitbook.io/easyvalidation/usage/collection-extensions)
* Create your own custom rules - [Details](https://wajahatkarim.gitbook.io/easyvalidation/usage/create-custom-rules)## ❓ Quick Usage
For example, you can validate any email `String` like this:
```kotlin
var myEmailStr = "[email protected]"
var isValid = myEmailStr.validEmail() // isValid will be true or false
// Or you can also validate with an error callback method
myEmailStr.validEmail() {
// This method will be called when myEmailStr is not a valid email.
Toast.makeText(contex, it, Toast.LENGTH_SHORT).show()
}
```
These extension methods are also available for `String`, `EditText`, `TextView`, `AutoCompleteTextView`, `TextInputLayout`, and `Spinner`.
```kotlin
var myEditText = findViewById(R.id.myEditText)
var isValid = myEditText.nonEmpty() // Checks if edit text is empty or not// Or with error callback method like this
myEditText.nonEmpty() {
// This method will be called when myEditText is empty.
myEditText.error = it
}
```
There are around 30+ built-in rules in the core module library. You can check all these in [Rules page](https://wajahatkarim.gitbook.io/easyvalidation/usage/built-in-rules).
EasyValidation also supports multiple validation checks at same time using [Validator class](https://wajahatkarim.gitbook.io/easyvalidation/usage/untitled) like this:
```kotlin
// This example will check that whether user entered password has
// atleast one number, one spcial character, and one upper case.
var txtPassword = findViewById(R.id.txtPassword)
txtPassword.validator()
.nonEmpty()
.atleastOneNumber()
.atleastOneSpecialCharacters()
.atleastOneUpperCase()
.addErrorCallback {
txtPassword.error = it
// it will contain the right message.
// For example, if edit text is empty,
// then 'it' will show "Can't be Empty" message
}
.check()
```For more advanced usage, checkout the [full documentation at GitBook page](https://wajahatkarim.gitbook.io/easyvalidation/).
## 💰 Donations
This project needs you! If you would like to support this project's further development, the creator of this project or the continuous maintenance of this project, feel free to donate. Your donation is highly appreciated (and I love food, coffee and beer). Thank you!
**PayPal**
* **[Donate $5](https://www.paypal.me/WajahatKarim/5)**: Thank's for creating this project, here's a tea (or some juice) for you!
* **[Donate $10](https://www.paypal.me/WajahatKarim/10)**: Wow, I am stunned. Let me take you to the movies!
* **[Donate $15](https://www.paypal.me/WajahatKarim/15)**: I really appreciate your work, let's grab some lunch!
* **[Donate $25](https://www.paypal.me/WajahatKarim/25)**: That's some awesome stuff you did right there, dinner is on me!
* **[Donate $50](https://www.paypal.me/WajahatKarim/50)**: I really really want to support this project, great job!
* **[Donate $100](https://www.paypal.me/WajahatKarim/100)**: You are the man! This project saved me hours (if not days) of struggle and hard work, simply awesome!
* **[Donate $2799](https://www.paypal.me/WajahatKarim/2799)**: Go buddy, buy Macbook Pro for yourself!Of course, you can also choose what you want to donate, all donations are awesome!
## 👨 Developed By
```
Wajahat Karim
```
- Website (http://wajahatkarim.com)
- Twitter (http://twitter.com/wajahatkarim)
- Medium (http://www.medium.com/@wajahatkarim3)
- LinkedIn (http://www.linkedin.com/in/wajahatkarim)# 👍 How to Contribute
1. Fork it
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create new Pull Request# 📃 License
Copyright 2018 Wajahat Karim
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 athttp://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.