• Stars
    star
    139
  • Rank 262,954 (Top 6 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 7 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Android library for fast and simple string validation

Android library for fast and simple string validation.

Built with ❀︎ by Nishant Srivastava and contributors


Including in your project

ValidateTor is available in Jcenter, so getting it as simple as adding it as a dependency

implementation 'com.github.nisrulz:validatetor:{latest version}'

where {latest version} corresponds to published version in Download

Usage

  1. Init ValidateTor

    Java

    ValidateTor validateTor = new ValidateTor();

    Kotlin

    var validateTor = ValidateTor();
  2. Validate string against the type of validation method from ValidateTor

    // i.e To validate a password string
    EditText edt_password = findViewById(R.id.edt_password);
    String str = edt_password.getText().toString();
    
    // Check if password field is empty
    if (validateTor.isEmpty(str)) {
      edt_password.setError("Field is empty!");
    }
    
    // Check password string to be of minimum length of 8 characters and should have
    // atleast 1 digit, 1 upppercase letter and 1 special character
    if (validateTor.isAtleastLength(str, 8)
        && validateTor.hasAtleastOneDigit(str)
        && validateTor.hasAtleastOneUppercaseCharacter(str)
        && validateTor.hasAtleastOneSpecialCharacter(str)) {
    
        // Valid Password
    
    } else {
       // Invalid Password, handle in ui
        edt_password.setError("Password needs to be of minimum length of 8 characters and should have " +
          "atleast 1 digit, 1 upppercase letter and 1 special character ");
    }

    ... other possible validations are as below:

    Method Name Description Return Type
    containsSubstring(String str, String seed) Check if the string contains the seed boolean
    isAlpha(String str) Check if the string contains only letters boolean
    isAlphanumeric(String str) Check if the string contains only letters and numbers boolean
    isBoolean(String str) Check if a string is a boolean boolean
    isIPAddress(String str) Check if the string is a ip address boolean
    isEmail(String str) Check if the string is a email address boolean
    isPhoneNumber(String str) Check if the string is a US phone number boolean
    isEmpty(String str) Check if the string has a length of zero boolean
    isBase64(String str) Check if a string is base64 encoded boolean
    isDecimal(String str) Check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc boolean
    isAtleastLength(String str, int len) Check if the string is of atleast the specified length boolean
    isAtMostLength(String str, int len) Check if the string is of atmost the specified length boolean
    isLowercase(String str) Check if the string is all lowercase boolean
    isUppercase(String str) Check if the string is all uppercase boolean
    isValidMD5(String str) Check if the string is a valid MD5 hash boolean
    isNumeric(String str) Check if the string contains only numbers boolean
    isMACAddress(String str) Check if the string is a MAC address boolean
    isJSON(String str) Check if the string is valid JSON boolean
    isInteger(String str) Check if the string is an integer boolean
    isIn(String str, String[] values) Check if the string is present in an array of allowed values boolean
    isHexadecimal(String str) Check if the string is a hexadecimal number boolean
    isPinCode(String str) Check if the string is a pincode boolean
    isHexColor(String str) Check if the string is a hexadecimal color boolean
    hasAtleastOneDigit(String str) Check if the string has atleast one digit boolean
    hasAtleastOneLetter(String str) Check if the string has atleast one letter boolean
    hasAtleastOneLowercaseCharacter(String str) Check if the string has atleast one lowercase character boolean
    hasAtleastOneUppercaseCharacter(String str) Check if the string has atleast one uppercase character boolean
    hasAtleastOneSpecialCharacter(String str) Check if the string has atleast one special character boolean
    validateCreditCard(String str) Check if the string is a valid credit card number boolean
    getCreditCardInfo(String str) Get CreditCard information from string CardInformation

Extending ValidateTor

If you wish to extend ValidateTor, use the RegexMatcher class. Create your own regex matchers by passing in a valid regex string to validate() or find()

Method Name Description Return Type
validate(String dataStr, String regex) Validate string against a regex boolean
validate(String dataStr, Pattern pattern) Validate string against a pattern boolean
find(String dataStr, String regex) Find in string against a regex boolean
find(String dataStr, Pattern pattern) Find in string against a pattern boolean

License

Licensed under the Apache License, Version 2.0, click here for the full license.

Author & support

This project was created by Nishant Srivastava but hopefully developed and maintained by many others. See the the list of contributors here.

If you appreciate my work, consider buying me a cup of β˜• to keep me recharged 🀘

I love using my work and I'm available for contract work. Freelancing helps to maintain and keep my open source projects up to date!

More Repositories

1

flutter-examples

[Examples] Simple basic isolated apps, for budding flutter devs.
Dart
6,550
star
2

android-tips-tricks

β˜‘οΈ [Cheatsheet] Tips and tricks for Android Development
Java
4,680
star
3

app-privacy-policy-generator

A simple web app to generate a generic privacy policy for your Android/iOS apps
Sass
3,415
star
4

sensey

⚑ [Android Library] Play with sensor events & detect gestures in a breeze.
Java
2,676
star
5

easydeviceinfo

πŸ“± [Android Library] Get device information in a super easy way.
Java
1,736
star
6

android-examples

:shipit: [Examples] Simple basic isolated apps, for budding android devs.
Java
1,732
star
7

recyclerviewhelper

πŸ“ƒ [Android Library] Giving powers to RecyclerView
Java
639
star
8

qreader

πŸ”³ [Android Library] Read QR codes using google's mobile vision api, but without the hassle
Java
368
star
9

screenshott

[Android Library] Take a screenshot of your view layout , programmatically!
Java
325
star
10

android-utils

[Android Library] Facilitating some very common functionalities in the form of utility classes for Android
Java
142
star
11

packagehunter

πŸ“₯ [Android Library] Hunt down all package information
Java
140
star
12

twitterbot-nodejs

[Bot] A twitter bot made using nodejs which can post tweets, retweet other tweets and possibly fav tweets
JavaScript
139
star
13

zentone

πŸ”‰ [Android Library] Easily generate audio tone of a specific frequency and volume in Android.
Kotlin
109
star
14

javadoc-themer

[Javadoc Tool] Give your boooring javadocs a splash of colors!
HTML
83
star
15

lantern

[Android Library] Handling device flash as torch for Android.
Java
82
star
16

FirebaseExample

πŸ”₯ Simplistic example app demonstrating using latest Firebase features. Checkout branches for each feature.
Java
60
star
17

UploadToBintray

[Example] Awesome library built to demonstrate the process of publishing android libraries via JCenter/Bintray
Java
53
star
18

java-interview-questions

Byte sized java tech interview coding questions
Java
43
star
19

nisrulz.github.io

Everything about Nishant Srivastava/nisrulz (online alias)
CSS
43
star
20

UploadToJitpack

[Example] Base repository to demonstrate the process of uploading an aar/jar to JitPack
Kotlin
39
star
21

OptimusHTTP

πŸ“‘ [Android Library] Simplified async networking in android
Java
35
star
22

terminal-utils

[Utils] A growing list of useful terminal utility/commands and bash scripts to automate your life!
Shell
33
star
23

twitterbot-java

[Bot] Twitter bot to automate few tasks on twitter.
Java
16
star
24

ShoutOut

[Android Library] Log information in android
Kotlin
15
star
25

SelfieApp

A simple app to demonstrate building applications in android. The app lets you take selfies and show it as list inside the app.
Java
14
star
26

EvTrack

[Android Library] Make event and exception tracking like a piece of cake
Java
13
star
27

LearnKotlin

[Example] Learning Kotlin programming in Android
Kotlin
12
star
28

AndroidAutomations

An android example app to demonstrate various automations possible.
Kotlin
10
star
29

convert-md-to-pdf

Convert Markdown to PDF
JavaScript
10
star
30

puppeteer-examples

[Examples] Simple basic isolated node scripts for doing stuff with puppeteer
JavaScript
8
star
31

android-lib-init-examples

[Examples] Simple basic isolated android examples to showcase various library initialization mechanisms
Kotlin
8
star
32

SupportCamera

[Android Library] Support library to handle camera api on all android versions
Java
7
star
33

UploadToMavenCentral

[Example] Base repository to demonstrate the process of uploading an aar/jar to maven central.
Kotlin
7
star
34

nisrulz

Github Frontpage
5
star
35

ortwin-slack-bot

πŸ›Ž Your point friend in the slack workspace
JavaScript
5
star
36

Parallax-One-Pager-Template

[Template] A simple one pager parallax scrolling template
HTML
5
star
37

angular-seed

[Template] A simple angular-based seed website
CSS
4
star
38

gradle-playground

Sample project for raywenderlich.com tutorial
Kotlin
4
star
39

JetSetCompose

Example app for Jet Set Compose talk
Kotlin
4
star
40

kmp-examples

Main repository containing all the example apps demonstrating features/functionality/integrations using Kotlin MultiPlatform development.
Kotlin
4
star
41

nisrulz-android-settings

[Config] Android Studio settings and code styles used by me
3
star
42

mavenrepo

[Example] Github-Based Maven Repository
3
star
43

LearnRetrofit

[Example] Learning how to use retrofit android library
Java
3
star
44

release-automation-playstore

An automated workflow to update Playstore metadata for an android application.
Ruby
3
star
45

CoroutineRecipes

Executable example code from my talk "Cooking with Coroutines Recipes"
Kotlin
3
star
46

bygone-projects

This repository contains projects that I had worked upon in my past, possibly when I was at school (pre-college).
C++
2
star
47

advent-of-code-2021

Repository with solutions for Advent Of Code 2021 puzzles.
2
star
48

android-dev-wrapped-generator

A simple web app to generate your own Android Dev Wrapped!
HTML
2
star
49

.github

Default community health files
1
star
50

gcm-nodejs-server

[NodeJS] NodeJS GCM Server
JavaScript
1
star
51

KotlinCompileFromCmdLine

This is a repository to compile a pure kotlin project without a build system such as Gradle.
Kotlin
1
star
52

release-automation-apple-connect

An automated workflow to update Apple Appstore metadata for an iOS application.
Ruby
1
star