This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@techmmunity/easy-check
TypeScript icon, indicating that this package has built-in type declarations

3.3.2 • Public • Published

Techmmunity Easy Check

CodeFactor DeepScan grade Coverage Status tests npm Downloads

All projects that involve programming work with data at some level, and the most worrying thing about that data is its reliability.

If any data on your system is outside the expected and accepted standard, this can generate unforeseen bugs, which will give you a lot of headaches.

With that in mind, we created Techmmunity Easy Check, a simple library that seeks to solve all your problems with validation.

Our main goals with this lib:

  • ZERO dependencies (there's no blind spot, you can see exactly how it's being validated)
  • Extremely intuitive
  • Highly reliable
  • Highly predictable (each method returns true or false, there's no third option)

Guilded Badge

Install

With Yarn:

yarn add @techmmunity/easy-check

With NPM:

npm i @techmmunity/easy-check

Upgrading

2.x > 3.x

The easier way to upgrade to version 3.x, is changing the import method, like this:

// 2.x:
import { check } from "@techmmunity/easy-check";

// 3.x:
import * as check from "@techmmunity/easy-check";

Usage

import { isEmail } from "@techmmunity/easy-check";

if (isEmail("example@email.com")) {
	// ...
}

How to contribute?

All the details about contributing to the project are described here.

Methods - Table Format

Strings

Method How To Use
isCPF isCPF("55357314047")
isMaskedCPF isMaskedCPF("553.573.140-47")
isEmail isEmail("example@email.com")
isEmoji isEmoji("😂")
hasEmojis hasEmojis("Yes, there is emojis here 😂")
isHerokuApiKey isHerokuApiKey("625628d3-8a45-466e-a55e-ead5c6886887")
hasHtmlTags hasHtmlTags("Foo <b>Bar</b>")
isIpv4 isIpv4("192.168.1.1")
isIpv4WithMask isIpv4WithMask("192.168.1.1/24")
isStrongPassword isStrongPassword("$t0ngP@ssw0rD")
isBrazillianPhone isBrazillianPhone("2199999999")
isUrl isUrl("https://google.com")
hasUrl hasUrl("foo bar https://google.com foo bar")
isSimpleUsername isSimpleUsername("foo-bar")
isUUIDv4 isUUIDv4("24bd85a1-4eb7-4f63-829e-75c08ac2b6c0")

Colors

Method How To Use
isDarkHexColor isDarkHexColor("#000000")
isHexColor isHexColor("#000")
isLightHexColor isLightHexColor("#ffffff")

Numbers

Method How To Use
isDivisibleByTen isDivisibleByTen(10)
isEven isEven(2)
isNumeric isNUmeric("123")
isOdd isOdd(1)

Dates

Method How To Use
isDateDMY isDateDMY("31-01-2020")
isDateDMYS isDateDMYS("31/01/2020")
isDateMDY isDateMDY("01-31-2020")
isDateMDYS isDateMDYS("01/31/2020")
isDateYMD isDateYMD("2020-01-31")
isDateYMDS isDateYMDS("2020/01/31")
isLeap isLeap("2020")

Methods - Detailed Description

Strings

isCpf

Check if the string is a CPF (brazzilian federal tax id).

import { isCpf } from "@techmmunity/easy-check";

if (isCpf("55357314047")) {
	// ...
}

isMaskedCpf

Check if the string is a masked CPF (brazzilian federal tax id).

import { isMaskedCpf } from "@techmmunity/easy-check";

if (isMaskedCpf("553.573.140-47")) {
	// ...
}

isEmail

Check if the string is a valid email.

import { isEmail } from "@techmmunity/easy-check";

if (isEmail("example@email.com")) {
	// ...
}

isEmoji

Check if the string is an emoji.

import { isEmoji } from "@techmmunity/easy-check";

if (isEmoji("😂")) {
	// ...
}

hasEmoji

Check if the string has at least one emoji.

import { hasEmoji } from "@techmmunity/easy-check";

if (hasEmoji("Yes, there is emojis here 😂")) {
	// ...
}

isHerokuApiKey

Check if the string is in the heroku api key format.

Alert: This doens't validates if the api key is valid! Only if it's on the correct format.

import { isHerokuApiKey } from "@techmmunity/easy-check";

if (isHerokuApiKey("625628d3-8a45-466e-a55e-ead5c6886887")) {
	// ...
}

hasHtmlTags

Check if the string contains html tags like.

Alert: This doens't validates if the html tags are valid! Only if there is something that look likes a html tag.

import { hasHtmlTags } from "@techmmunity/easy-check";

if (hasHtmlTags("Foo <b>Bar</b>")) {
	// ...
}

isIpv4

Check if the string is a valid ipv4.

import { isIpv4 } from "@techmmunity/easy-check";

if (isIpv4("192.168.1.1")) {
	// ...
}

isIpv4WithMask

Check if the string is a valid ipv4 with mask.

import { isIpv4WithMask } from "@techmmunity/easy-check";

if (isIpv4WithMask("192.168.1.1/24")) {
	// ...
}

isStrongPassword

Check if the string is a strong password.

  • At least 6 characters
  • At most 100 characters
  • At least one Uppercase
  • At least one Lowercase
  • At least one Number
  • At least one of @#$!%\*?&
import { isStrongPassword } from "@techmmunity/easy-check";

if (isStrongPassword("$t0ngP@ssw0rD")) {
	// ...
}

isBrazillianPhone

Check if the string is a valid brazzilian phone.

Alert: It doesn't validates if the phone existis or if it's really valid, just if it's in the correct format, includind validation by DDD.

import { isBrazillianPhone } from "@techmmunity/easy-check";

if (isBrazillianPhone("19999904610")) {
	// ...
}

isUrl

Check if the string is a valid url.

import { isUrl } from "@techmmunity/easy-check";

if (isUrl("https://google.com")) {
	// ...
}

hasUrl

Check if the string has a valid url.

import { hasUrl } from "@techmmunity/easy-check";

if (hasUrl("foo bar https://google.com foo bar")) {
	// ...
}

isSimpleUsername

Check if the string is a valid username.

  • 3 to 16 characters
  • Lower And Upper case allowed
  • Allows only aplhanumeric and - and _
import { isSimpleUsername } from "@techmmunity/easy-check";

if (isSimpleUsername("foo-bar")) {
	// ...
}

isUUIDv4

Check if the string is a valid uuid v4.

import { isUUIDv4 } from "@techmmunity/easy-check";

if (isUUIDv4("24bd85a1-4eb7-4f63-829e-75c08ac2b6c0")) {
	// ...
}

Colors

isDarkHexColor

Check if the string is a dark color in hex format.

import { isDarkHexColor } from "@techmmunity/easy-check";

if (isDarkHexColor("#000") || isDarkHexColor("#000000")) {
	// ...
}

isHexColor

Check if the string is a color in hex format.

import { isHexColor } from "@techmmunity/easy-check";

if (isHexColor("#000") || isHexColor("#000000")) {
	// ...
}

isLightHexColor

Check if the string is a light color in hex format.

import { isLightHexColor } from "@techmmunity/easy-check";

if (isLightHexColor("#fff") || isLightHexColor("#ffffff")) {
	// ...
}

Numbers

isDivisibleByTen

Check if a number is divisible by 10.

import { isDivisibleByTen } from "@techmmunity/easy-check";

if (isDivisibleByTen(10)) {
	// ...
}

isEven

Check if a number is even (divisible by 2).

import { isEven } from "@techmmunity/easy-check";

if (isEven(2)) {
	// ...
}

isNumeric

Check if a istring is made only by numbers

import { isNumeric } from "@techmmunity/easy-check";

if (isNumeric("123")) {
	// ...
}

isOdd

Check if a number is odd (NOT divisible by 2).

import { isOdd } from "@techmmunity/easy-check";

if (isOdd(3)) {
	// ...
}

Dates

isDateDMY

Check if the string is a date in the DD-MM-YYYY format.

Bonus: This validates if it's a valid date too!

import { isDateDMY } from "@techmmunity/easy-check";

if (isDateDMY("31-01-2020")) {
	// ...
}

isDateDMYS

Check if the string is a date in the DD/MM/YYYY format.

Bonus: This validates if it's a valid date too!

import { isDateDMYS } from "@techmmunity/easy-check";

if (isDateDMYS("31/01/2020")) {
	// ...
}

isDateMDY

Check if the string is a date in the MM-DD-YYYY format.

Bonus: This validates if it's a valid date too!

import { isDateMDY } from "@techmmunity/easy-check";

if (isDateMDY("01-31-2020")) {
	// ...
}

isDateMDYS

Check if the string is a date in the MM/DD/YYYY format.

Bonus: This validates if it's a valid date too!

import { isDateMDYS } from "@techmmunity/easy-check";

if (isDateMDYS("01/31/2020")) {
	// ...
}

isDateYMD

Check if the string is a date in the YYYY-MM-DD format.

Bonus: This validates if it's a valid date too!

import { isDateYMD } from "@techmmunity/easy-check";

if (isDateYMD("2020-01-31")) {
	// ...
}

isDateYMDS

Check if the string is a date in the YYYY/MM/DD format.

Bonus: This validates if it's a valid date too!

import { isDateYMDS } from "@techmmunity/easy-check";

if (isDateYMDS("2020/01/31")) {
	// ...
}

isLeap

Check if the string or the number is leap year (year with February 29).

Bonus: This validates if it's a valid year too!

import { isLeap } from "@techmmunity/easy-check";

if (isLeap("2020") || isLeap(2020)) {
	// ...
}

Package Sidebar

Install

npm i @techmmunity/easy-check

Weekly Downloads

2

Version

3.3.2

License

Apache-2.0

Unpacked Size

69.8 kB

Total Files

37

Last publish

Collaborators

  • henriqueleite42