Coder Social home page Coder Social logo

taimoorimran / t-val Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 29 KB

t-val is an input validator, can be used with the input field and you can define set of rules to apply on field.

License: MIT License

JavaScript 100.00%
input react field sanitize

t-val's Introduction

Logo of t-val

Build Status npm

t-val is an input validator, can be used with the input field and you can define set of rules to apply on input field.

Here's the Code Sandbox!

Installation

Installing the package.

$ npm install @taimoorimran/tval

Usage

// importing the package
    import tval from '@taimoorimran/tval';
// calling the function
    const config = { 
        ...
    }
    console.log(tval('value', config));

Configuration

Length

Rule Type Value Description
minLength int - Length of string should be greater
const config = {
    minLength: 5
}
Rule Type Value Description
maxLength int - Length of string should be lesser
const config = {
    maxLength: 5
}
Rule Type Value Description
length int - Length of string should be equals to
const config = {
    length: 5
}

Alphabets

Rule Type Value Description
allowUpper bool Default: False Allow upper case characters in string - [A-Z]
const config = {
    characters: {
        allowUpper: // true / false
    }
}
Rule Type Value Description
allowLower bool Default: False Allow lower case characters in string - [a-z]
const config = {
    characters: {
        allowLower: // true / false
    }
}

Numerals

Rule Type Value Description
allowNumeric bool Default: False Allow numerals in string - [0-9]
const config = {
    allowNumeric: // true / false
}

Space

Rule Type Value Description
dontAllowSpace bool Default: False Allow spaces in string
const config = {
    dontAllowSpace: // true / false
}

Special Characters

Rule Type Value Description
allowAll bool Default: False Allow special characters => [!, @, #, $, %, ^, &, *]
const config = {
    specialCharacters: {
        allowAll: // true / false
    }
}
Rule Type Value Description
onlyAllowThese bool Default: False Add selective special characters
const config = {
    specialCharacters: {
        onlyAllowThese: '&#_-'
    }
}

Overview

const config = {
    minLength: 1,
    maxLength: 5,
    //OR
    length: 10,
    allowNumeric: // true / false,
    characters: {
        allowUpper: // true / false,
        allowLower: // true / false
    },
    specialCharacters: {
        allowAll: // true / false,
        onlyAllowThese: '&#_-'
    }
}

License

t-val is MIT licensed.

Powered By

Logo of 7ctech

t-val's People

Contributors

taimoorimran avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

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.