GithubHelp home page GithubHelp logo

wassimbj / itiz Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 85 KB

well tested, and easy to use js validation library

License: MIT License

JavaScript 97.06% HTML 2.94%
validation javascript browser server utils

itiz's Introduction

What is this ?

this is a js validation library, works on the browser as well as on the server, it is well tested with the help of QUnit. hope you find it helpful.

On the Browser:

if you want to use "itiz" on the browser, just download and then load the itiz.min.js file.

    <script src='./your_project/path/to/itiz.min.js'></script> 

On the Server:

if you are using some server side js frameworks like Nodejs, you just need to npm install it

    npm i itiz 

and the simply require it as you do with any other package

API & Usage

itiz(param)

this is the main function, this will return an object of all the helpful methods that you can use.
param is required, you will get an error if you dont pass anything
those are the methods you get after calling itiz() with params;

.email()

this method will validate the email you pass to the itiz() function
usage

    // this here will return an object (wich is a chain of all the other method,
    // or false if the email is not valid
    itiz('[email protected]').email();

.length(params)

this method will validate the string you give to the itiz() function
usage

    // will return an object (wich is a chain of all the other method or false if itiz not valid
    itiz('this is a long string').length({max: 20});

params
parameters are required, and it must be an object that has one of this:
min: the minimum length of the string
max: the maximum length of the string

.same()

this method will ensure if two (or more) values are the same (equal) usage

    // this will return an object (wich is a chain of all the other method or false if the two values are not the same
    itiz(['password_123', 'password_123']).same();

    // You can pass as many values as you can to check if they are all the same
    // e.g:
    itiz(['doe', 'doe', 'doe', 'doe']).same();

.url([params])

this method here will validate if a given url is valid
usage

    // this will return an object (wich is a chain of all the other method or false if the two values are not the same
    itiz('www.facebook.com').url();

params
this method accepts one parameter wich is a boolean value (default is false). if you pass true to it, it will ensure that that the url must contain the protocol (http/https)

    // e.g:
    itiz('www.google.com').url(true) // this will return false

.contains(params)

this method will validate if a string or array contains a specific value;
this method will return only boolean value (true/false), it wont return an object

usage

    
    // with strings
    itiz('i love harry potter').contains('potter') // will return true

    // with arrays
    itiz(['harry', 'ron', 'hermione']).contains('voldemort') // will return false

.notEmpty()

this method will validate if an array/object/string is not empty it will return an object if valid or false if not

usage

    itiz(['harry', 'ron', 'hermione']).notEmpty() // will return an object with the other helpful methods
    
    itiz({}).notEmpty() // will return an false, well cause its empty

.empty()

this method will validate if an array/object/string is empty it will return an object if valid or false if not

usage

    itiz({name: 'hagrid'}).empty() // will return false

    itiz([]).empty() // will return an object with the other helpful methods

.upperCase([params])

this method will validate if an a string is upper case it will return an object if valid or false if not

usage

    itiz('HELLO WORLD').upperCase() // will return an object

    itiz('HELLO WOrLD').upperCase() // will return false

params
this method accepts one optional parameter wich is an object with an index property,
that can be a number or array of numbers. this parameter will ensure that the index given is upper-case

    // e.g:
    itiz('Hello world').upperCase({index: 0}) // will return an object, cause its valid :)

.lowerCase([params])

this method will validate if an a string is lower case it will return an object if valid or false if not

usage

    itiz('chamber of secrets').lowerCase() // will return an object

    itiz('Philosopher stone').lowerCase() // will return false

params
this method accepts one optional parameter wich is an object with an index property, same as the upperCase() method, that can be a number or array of numbers.

    // e.g:
    itiz('Magic Wand').lowerCase({index: 2}) // will return an object, cause its valid :)

Contribution

if you found this library helpful and you want to contribute, maybe add another helpful method or anything..., please go ahead.

itiz's People

Contributors

wassimbj avatar

Watchers

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