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

validatorrrr

v1.0.0

Published

A comprehensive validation library for common data validation tasks.

Downloads

1

Readme

validatorrr

npm version GitHub issues GitHub stars Visitors Twitter Follow

A comprehensive and light weight validation library for common data validation tasks.

Installation

You can install validatorrr via npm:

npm install validatorrr

Or include it via CDN:

<!-- Latest release -->
<script src="https://cdn.jsdelivr.net/gh/mr-shade/validatorrr@latest/validatorrr.js"></script>

<!-- <script src="https://cdn.jsdelivr.net/npm/validatorrr"></script> -->



<!-- Specific version (replace '1.0.0' with the desired version) -->
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> -->

Usage

Here's an example of how you can use validatorrr:

import v from 'validatorrr';
 // Usage example
// import v from './validatorrr.mjs';
// const v = require('./v.js');

console.log(v.isEmail('[email protected]')); // true
console.log(v.isURL('https://www.example.com')); // true
console.log(v.isNotEmptyString('Hello')); // true
console.log(v.isPalindrome('A man, a plan, a canal, Panama')); // true
console.log(v.isPalindrome('IamnotPalindrome')); // false

console.log(v.isWithinRange(5, 1, 10)); // true
console.log(v.isInArray('apple', ['banana', 'apple', 'orange'])); // true
console.log(v.isUUID('123e4567-e89b-12d3-a456-426614174000')); // true
console.log(v.isHexColor('#ffcc00')); // true

console.log(v.isDateYYYYMMDD('2024-04-09')); // true
console.log(v.isCreditCard('4111-1111-1111-1111')); // true
console.log(v.isPhoneNumber('+1234567890')); // true
console.log(v.isPostalCode('12345')); // true
console.log(v.isStrongPassword('Nndw$%623!')); // true
console.log(v.isAlpha('abcdefghijklmnopqrstuvwxyz')); // true
console.log(v.isAlphanumeric('abc123')); // true
console.log(v.isNumeric('12345')); // true

Features

  • isEmail(email): Checks if a string is a valid email address.
  • isURL(url): Checks if a string is a valid URL.
  • isNotEmptyString(str): Checks if a string is not empty.
  • isPalindrome(str): Checks if a string is a palindrome.
  • isWithinRange(num, min, max): Checks if a number is within a specified range.
  • isInArray(value, array): Checks if a value exists in an array.
  • isUUID(uuid): Checks if a string is a valid UUID.
  • isHexColor(color): Checks if a string is a valid HEX color.
  • isDateYYYYMMDD(dateString): Checks if a string is a valid date in the format YYYY-MM-DD.
  • isCreditCard(cardNumber): Checks if a string is a valid credit card number.
  • isPhoneNumber(phone): Checks if a string is a valid phone number.
  • isPostalCode(postalCode, countryCode): Checks if a string is a valid postal code.
  • isStrongPassword(password): Checks if a string is a strong password.
  • isAlpha(str): Checks if a string contains only alphabetic characters.
  • isAlphanumeric(str): Checks if a string contains only alphanumeric characters.
  • isNumeric(str): Checks if a string contains only numeric characters.

Usage via CDN

You can also use validatorrr directly in the browser via CDN:

<!-- Latest release -->
<script src="https://cdn.jsdelivr.net/npm/validatorrr"></script>

<!-- Specific version (replace '1.0.0' with the desired version) -->
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> -->

Documentation

isEmail(email)

Checks if a string is a valid email address.

Parameters:

  • email: String - The email address to validate.

Example:

const isValidEmail = validatorrr.isEmail('[email protected]');
console.log(isValidEmail); // true

isURL(url)

Checks if a string is a valid URL.

Parameters:

  • url: String - The URL to validate.

Example:

const isValidURL = validatorrr.isURL('https://www.example.com');
console.log(isValidURL); // true

isNotEmptyString(str)

Checks if a string is not empty.

Parameters:

  • str: String - The string to check.

Example:

const isValid = validatorrr.isNotEmptyString('Hello');
console.log(isValid); // true

Issues

If you encounter any issues or have suggestions, please feel free to open an issue on GitHub.

License

This project is licensed under the MIT License - see the LICENSE file for details.


https://dev.to/sh20raj/xvalidatorrr-a-lightweight-validation-library-for-javascript-2c59