Git Product home page Git Product logo

vanguard's Introduction

VanGuard

An easy-to-use, real-time UI form validation library for Android.

Installation

1 Add the JitPack repository to your root build.gradle:

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

2 Add VanGuard dependency to your app build file

     implementation 'com.github.baianat:VanGuard:0.1.0'

Quick Guide

Define a set of validation cases, each of which must include:

  • A validaion rule based on which the validation status of the view can be determined as true or false.
  • The view on which the validaion rule is tested.
      val emailValidationCase = CasesFactory
          .watch(emailEditText)
          .forRule(IsEmail(errorMsg = "Please enter a valid e-mail!"))
          .create()
          
      val passwordValidationCase = CasesFactory
          .watch(passwordEditText)
          .forRule(IsLengthGreaterThan(length = 5,errorMsg = "Password can't be less than 6 chars!"))
          .create()
          
      val notificationValidationCase = CasesFactory
          .watch(notificationsCheckBox)
          .forRule(IsChecked())
          .create()

Initialize VanGuard in the Activity or Frament of interest, and link it to the validation cases.

      VanGuard.of(this)
          ?.validate(emailValidationCase, passwordValidationCase, notificationValidationCase)

Listen to the Callback for form status changes between being true and false (optional).

      VanGuard.of(this)
          ....
          .doOnFormStatusChange {isFormValid ->
              // isFormValid : true or false, based on the state of the form!
          }

Detailed Guide

For a detailed guide on how to use VanGuard, refer to the Wiki.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.