npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

validateer

v1.0.8

Published

A validating library for javascript

Downloads

2

Readme

Validateer

enter image description here

About

Validateer, is a small package that helps you work on form and string validation. You can also use the provided methods for general validation. This library is used on a string. coerce your input to string to prevent error.

Features

  • A very light-weight library
  • Fully tested on all end
  • Zero dependencies

Installation

Using NPM

npm i validateer

Using CDN

<script src="https://unpkg.com/validateer"></script>

Usage

So to use the various methods on validateer. follow the process.

CDN

A global variable 'vd' is created to be equal to Validateer. So this makes it easy to call validateer

vd("hello"); //return object Validateer.init {elem: "ibk", message: " "}

Import Using the ES6 import with validateer.

import { vd } from 'validateer'

or

let vd = require(validateer).vd

Methods

validateEmail - A method to validate an email. Parameters : Pattern - An optional field that takes a regular expression to validate email. callback - An optional function that takes the returned object as a parameter

vd("[email protected]").validateEmail(); //return {elem: "[email protected]", message: true/false} or vd("[email protected]").validateEmail(/^\w+([.-]?\w+)@\w+([.-]?\w+)(.\w{2,3})+$/, (obj) => { console.log(obj.elem + " " + obj.message) }); //return {elem: "[email protected]", message: true/false}

validateEmpty - A method to validate if a string is empty. Parameter : callback - An optional function that takes the returned object as a parameter

vd("").validateEmpty(); //return {elem: "", message: true/false} or vd("").validateEmpty((obj) => { console.log(obj.elem + " " + obj.message) }); //return {elem: "", message: true/false}

validateLetters - A method to validate if a string contains only letters. Parameters : Pattern - An optional field that takes a regular expression to validate only alphabet. callback - An optional function that takes the returned object as a parameter

vd("Hello").validateLetters(); //return {elem: "Hello", message: true/false} or vd("Hello").validateLetters(/^[a-z]+$/, (obj) => { console.log(obj.elem + " " + obj.message) }); //return {elem: "Hello", message: true/false}

validateNumber - A method to validate if a string contains only numbers. Parameters : Pattern - An optional field that takes a regular expression to validate only numbers. callback - An optional function that takes the returned object as a parameter

vd("1234").validateNumber(); //return {elem: "1234", message: true/false} or vd("12.5").validateNumber(/^[0-9]*.[0-9]+$/, (obj) => { console.log(obj.elem + " " + obj.message) }); //return {elem: "12.5", message: true/false}

validateAlphaNumeric - A method to validate if a string contains alphabet and numbers. Parameters : Pattern - An optional field that takes a regular expression to validate for alphabet and numbers. callback - An optional function that takes the returned object as a parameter

vd("hello67").validateAlphaNumeric(); //return {elem: "hello67", message: true/false} or vd("hello67").validateAlphaNumeric(/^[0-9a-z]*$/, (obj) => { console.log(obj.elem + " " + obj.message) }); //return {elem: "hello67", message: true/false}

validateLength - A method to validate if a string length is greater than a number and lesser than a number. Parameters : minlength - A compulsory field of what the minimum length of the string should be. maxlength - A compulsory field of what the maximum length of the string should be. callback - An optional function that takes the returned object as a parameter

vd("Hello World").validateLength(5, 12); //return {elem: "Hello World", message: true/false} or vd("Hello World").validateLength(5, 12, (obj) => { console.log(obj.elem + " " + obj.message) }); //return {elem: "Hello World", message: true/false}

validateDate - A method to validate if a date matches your pattern or default pattern. Parameters : Pattern - An optional field that takes a regular expression to validate the date format. callback - An optional function that takes the returned object as a parameter

vd("12-9-2020").validateDate(); //return {elem: "12-9-2020", message: true/false} or vd("09/27/2020").validateDate(/^(0?[1-9]|1[012])/-[/-]\d{4}$/, (obj) => { console.log(obj.elem + " " + obj.message) }); //return {elem: "09/27/2020", message: true/false}

validatePhoneNumber - A method to validate if phone number passes the regex test for phone number. Parameters : Pattern - An optional field to replace default pattern which takes a regular expression to validate the phone number. callback - An optional function that takes the returned object as a parameter

vd("+1 0656 6788").validatePhoneNumber(); //return {elem: "+1 0656 6788", message: true/false} or vd("2347897899").validatePhoneNumber(/^\d{10}$/, (obj) => { console.log(obj.elem + " " + obj.message) }); //return {elem: "2347897899", message: true/false}

validatePassword - A method to validate if password passes the regex test for a password. Parameters : Pattern - An optional field to replace default pattern which takes a regular expression to validate the password. callback - An optional function that takes the returned object as a parameter.

vd("hello11").validatePassword(); //return {elem: "hello11", message: true/false} or vd("hello11").validatePassword(/^[A-Za-z]\w{7,14}$/, (obj) => { console.log(obj.elem + " " + obj.message) }); //return {elem: "hello11", message: true/false}

validateUrl - A method to validate if passed url passes the regex test for url. Parameters : Pattern - An optional field to replace default pattern which takes a regular expression to validate the url. callback - An optional function that takes the returned object as a parameter.

vd("http://www.example.com").validateUrl(); //return {elem: "http://www.example.com", message: true/false} or vd("http://www.example.com").validateUrl(/(http|https)://(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(/|/([\w#!:.?+=&%@!-/]))?/, (obj) => { console.log(obj.elem + " " + obj.message) }); //return {elem: "http://www.example.com", message: true/false}

MIT © helloibk · GitHub @ibk-code >