All Projects → rizmaulana → SheenValidator

rizmaulana / SheenValidator

Licence: MIT license
Android library to make form validation easier

Programming Languages

kotlin
9241 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to SheenValidator

Validator
A tool to validate text inside TextInputLayout
Stars: ✭ 117 (+303.45%)
Mutual labels:  validator, edittext
Validator.js
String validation
Stars: ✭ 18,842 (+64872.41%)
Mutual labels:  input, validator
passport
A Kotlin-based Android view validation library with a simple DSL.
Stars: ✭ 31 (+6.9%)
Mutual labels:  input, edittext
CurrencyEditText
A simple EditText input designed to input decimal and currency values.
Stars: ✭ 18 (-37.93%)
Mutual labels:  input, edittext
python-valid8
Yet another validation lib ;). Provides tools for general-purpose variable validation, function inputs/outputs validation as well as class fields validation. All entry points raise consistent ValidationError including all contextual details, with dynamic inheritance of ValueError/TypeError as appropriate.
Stars: ✭ 24 (-17.24%)
Mutual labels:  input, validator
FilterInputJs
Tiny and Powerful Library for limit an entry (text box,input) as number,string or more...
Stars: ✭ 37 (+27.59%)
Mutual labels:  input, validator
swagger-object-validator
Node-Module to validate your model against a swagger spec and receive in-depth error traces
Stars: ✭ 27 (-6.9%)
Mutual labels:  validator
MaiSense
Touch Sensor Emulation for SDEY - 💦 Touchlaundry Disco
Stars: ✭ 110 (+279.31%)
Mutual labels:  input
ra-input-markdown
A markdown editor for react-admin
Stars: ✭ 22 (-24.14%)
Mutual labels:  input
Hyena
鬣狗快速开发库(2018年6月停止维护)
Stars: ✭ 21 (-27.59%)
Mutual labels:  edittext
kindaVim.theapp
Ultimate Vim Mode for macOS
Stars: ✭ 372 (+1182.76%)
Mutual labels:  input
svelte-multiselect
Keyboard-friendly, accessible and highly customizable multi-select component
Stars: ✭ 91 (+213.79%)
Mutual labels:  input
romans
A Simple PHP Roman Numerals Library
Stars: ✭ 40 (+37.93%)
Mutual labels:  validator
tag-picker
Better tags input interaction with JavaScript.
Stars: ✭ 27 (-6.9%)
Mutual labels:  input
bootstrap5-tags
Replace select[multiple] with nices badges for Bootstrap 5
Stars: ✭ 58 (+100%)
Mutual labels:  input
vayder
Easy and concise validations for Express routes
Stars: ✭ 26 (-10.34%)
Mutual labels:  validator
typepy
A Python library for variable type checker/validator/converter at a run time.
Stars: ✭ 16 (-44.83%)
Mutual labels:  validator
Natours
An awesome tour booking web app written in NodeJS, Express, MongoDB 🗽
Stars: ✭ 94 (+224.14%)
Mutual labels:  validator
max-validator
Advanced validation library for Javascript & React | Inspired by laravel validation
Stars: ✭ 29 (+0%)
Mutual labels:  validator
vue-pincode-input
Great pincode input component
Stars: ✭ 128 (+341.38%)
Mutual labels:  input

SheenValidator

Android library to make form validation easier, it is simple and lightweight library 100% write in Kotlin

alt text

Installation

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

Add depedency

dependencies {
	implementation 'com.github.rizmaulana:SheenValidator:0.2.3'
}

Validation Support

  1. Required / Not Empty
  2. Email
  3. Phone
  4. Website
  5. Max Char Length
  6. Min Char Length

Usage

General Usage

    private lateinit var sheenValidator: SheenValidator
    ...

    override fun onCreate(savedInstanceState: Bundle?) {
        ...
        sheenValidator = SheenValidator(this)
        sheenValidator.setOnValidatorListener {
            Toast.makeText(this@SheenValidatorActivity, "Registration form is valid, good job!", Toast.LENGTH_SHORT)
                .show()
        }
        sheenValidator.registerAsRequired(txt_email)
        sheenValidator.registerAsEmail(txt_email)
        sheenValidator.registerAsRequired(txt_phone)
        sheenValidator.registerAsPhone(txt_phone)
        sheenValidator.registerAsRequired(txt_website)
        sheenValidator.registerAsWebsite(txt_website)
        sheenValidator.registerHasMin(txt_website, 5)

        btn_register.setOnClickListener {
            sheenValidator.validate()
        }
    }

You can register validation on any view which extends TextView component. SheenValidator has default error message like Email is required, email is not valid, etc if you dont use errorListener, but if you want to custom error message you can do it like this ...

Usage with Error Listener to custom Error

sheenValidator.setOnErrorValidatorListener { list ->
    list.forEach {
         when(it.id){
             R.id.txt_username -> til_username.error = "Oops!... looks like your username is not valid"
             R.id.txt_password -> til_password.error = "Hmm... password is required"
                }
            }
        }

Usage with Annotation

   lateinit var sheenValidator: SheenValidator

   @RegisterValidation(ValidationType.REQUIRED, 
   ValidationType.EMAIL)
   lateinit var txtUsername: TextInputEditText
   @RegisterValidation(ValidationType.REQUIRED)
   lateinit var txtPassword: TextInputEditText
   ...
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        ...
        txtUsername = findViewById(R.id.txt_email)
        txtPassword = findViewById(R.id.txt_password)

        sheenValidator = SheenValidator(this)
        sheenValidator.setOnValidatorListener {
            til_email.error = ""
            til_password.error = ""
            Toast.makeText(this@SheenValidatorAnnotationActivity, "Your form is valid, good job!", Toast.LENGTH_SHORT)
                .show()
        }
        ValidationBinder.bindValidator(sheenValidator, this)
        btn_login.setOnClickListener { sheenValidator.validate() }

 }

Contributing

Pull requests are welcome. we need more contributor for validation rule and default error language, in this version only support English as default error message

License

   MIT License

Copyright (c) 2019 rizmaulana

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].