Socket
Socket
Sign inDemoInstall

validatorrr

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    validatorrr

A comprehensive validation library for common data validation tasks.


Version published
Weekly downloads
4
Maintainers
1
Install size
16.6 kB
Created
Weekly downloads
 

Readme

Source

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/validatorrr@1.0.0"></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('test@example.com')); // 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/validatorrr@1.0.0"></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('test@example.com');
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

Keywords

FAQs

Last updated on 10 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc