All Projects → deadpixelsociety → passport

deadpixelsociety / passport

Licence: MIT license
A Kotlin-based Android view validation library with a simple DSL.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to passport

react-native-input-bar
Fully customizable, beautifully designed Input Bar for React Native
Stars: ✭ 32 (+3.23%)
Mutual labels:  input, text
TextInputLayout
The objective of this code is to guide you to create login screen with TextInputLayout in iOS app.
Stars: ✭ 30 (-3.23%)
Mutual labels:  input, text
AutoFormatInputWatcher
This repository contains input watcher for auto formatting digits in edit text
Stars: ✭ 15 (-51.61%)
Mutual labels:  text, edittext
FilterInputJs
Tiny and Powerful Library for limit an entry (text box,input) as number,string or more...
Stars: ✭ 37 (+19.35%)
Mutual labels:  input, input-validation
Insert Text At Cursor
Fast crossbrowser insertion of text at cursor position in a textarea / input
Stars: ✭ 49 (+58.06%)
Mutual labels:  input, text
pygame-text-input
a small module that enables you to input text with your keyboard using pygame
Stars: ✭ 114 (+267.74%)
Mutual labels:  input, text
read input
A simple CLI tool that asks for user input until the data inputted is valid.
Stars: ✭ 13 (-58.06%)
Mutual labels:  input, input-validation
Inputkit
📝InputKit, an Elegant Kit to limits your input text, inspired by BlocksKit, written in both Objective-C & ⚡️Swift.
Stars: ✭ 420 (+1254.84%)
Mutual labels:  input, text
CurrencyEditText
A simple EditText input designed to input decimal and currency values.
Stars: ✭ 18 (-41.94%)
Mutual labels:  input, edittext
SheenValidator
Android library to make form validation easier
Stars: ✭ 29 (-6.45%)
Mutual labels:  input, edittext
vue-scrollin
🎰 Scroll-in text component for Vue
Stars: ✭ 61 (+96.77%)
Mutual labels:  text
vue-pincode-input
Great pincode input component
Stars: ✭ 128 (+312.9%)
Mutual labels:  input
react-file-input-previews-base64
This package provides an easy to use, ready to go and customizable wrapper around file input, with option for image previews and returning file as base64 string.
Stars: ✭ 15 (-51.61%)
Mutual labels:  input
react-headless-phone-input
Headless phone number input component for React. Because phone numbers are hard.
Stars: ✭ 25 (-19.35%)
Mutual labels:  input
classy
Super simple text classifier using Naive Bayes. Plug-and-play, no dependencies
Stars: ✭ 12 (-61.29%)
Mutual labels:  text
kindaVim.theapp
Ultimate Vim Mode for macOS
Stars: ✭ 372 (+1100%)
Mutual labels:  input
bootstrap5-tags
Replace select[multiple] with nices badges for Bootstrap 5
Stars: ✭ 58 (+87.1%)
Mutual labels:  input
MaiSense
Touch Sensor Emulation for SDEY - 💦 Touchlaundry Disco
Stars: ✭ 110 (+254.84%)
Mutual labels:  input
als typograf
Ruby client for ArtLebedevStudio.RemoteTypograf Web Service.
Stars: ✭ 15 (-51.61%)
Mutual labels:  text
alfred-string-operations
Perform string operations to clipboard content
Stars: ✭ 70 (+125.81%)
Mutual labels:  text

passport

A Kotlin-based Android view validation library with a simple DSL.

Usage

Create Rules

Use the existing DSL rules or create custom rules to fit your needs. Capture the returned Passport object to invoke validation when required.

passport {
    rules<String>(phoneEdit) {
        numeric(getString(R.string.valid_phone_required))
    }
    
    rules<String>(emailLayout) {
        email()
        length(8, 32)
    }
    
    rules<Boolean>(switchView) {
        rule({ it }, { "The switch must be on." })
    }
}

You can also use the property delegate validator to setup your Passport object.

val validationRules by validator {
    rules<String>(phoneEdit) {
        numeric(getString(R.string.valid_phone_required))
    }
    
    rules<String>(emailLayout) {
        email()
        length(8, 32)
    }
    
    rules<Boolean>(switchView) {
        rule({ it }, { "The switch must be on." })
    }
}

Validate

A specific view, view group, fragment or activity can be targeted for validation.

val validator = passport { <snip> }
if(validator.validate(this, ValidationMethod.IMMEDIATE)) {
    // Valid!
}

Validation supports batch, fail fast, and immediate modes:

  • Batch - All views and rules are processed before validation is complete.
  • Fail Fast - All views are processed. For each view all rules are processed until the first failure is encountered.
  • Immediate - All views and rules are processed until a failure is found and validation completes immediately.

Validator Factories

Validators are provided to passport via validator factory functions.

Passport.validatorFactory({ TextViewValidator() })

Passport will assign the correct validator to a view during rule assignment based on it's class type. A specific validator can be assigned instead if desired.

Custom Validators

Custom validators allow for any view type to be managed. See the SwitchMaterial example.

See the example activity.

Gradle

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

dependencies {
    compile 'com.github.deadpixelsociety.passport:core:2.2'

    // 'material' includes a validator for the TextInputLayout view in the AndroidX material library. 
    //compile 'com.github.deadpixelsociety.passport:material:2.2'
    // 'fragment' includes a support for the AndroidX Fragment class. 
    //compile 'com.github.deadpixelsociety.passport:fragment:2.2'

    // 'design' includes a validator for the TextInputLayout view in the legacy design support library. 
    //compile 'com.github.deadpixelsociety.passport:design:2.2'
    // 'support-fragment' includes support for the legacy v4 Fragment class.
    //compile 'com.github.deadpixelsociety.passport:support-fragment:2.2'
}

License

The MIT License (MIT)

Copyright (c) 2019 deadpixelsociety

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].