/validatees

✅Validation library for ES6+ modules

Primary LanguageTypeScriptMIT LicenseMIT

validatees

Bundle size  Downloads  License  Version  GitHub Repo stars  GitHub issues

Validation package for ES6+, TypeScript and JavaScript(CommonJS and Module) ready.

Features

  • 🚀Easy to use: Easy to install in your project.
  • ES6+ && TS: TypeScript and ES6+ support(JS).
  • 🐭Small footprint: Less then 3kb package size.
  • 📦No dependencies: You don't depend on anything else.

Getting Started

Installation

To use this package, install using npm, yarn or pnpm📥:

# npm
npm install validatees
# yarn
yarn add validatees
# pnpm
pnpm install validatees

Usage

// ES6+ JavaScript CommonsJs
const validatees = require("validatees");
// TypeScript || ES6+ JavaScript module
import validatees from "validatees";

Types

Type checking can be difficult, but with validatees types, it's easy.

isFalsy:

Made from 'Falsy MDN defenition'.

const { isFalsy } = require("validatees");
isFalsy(0); // true
isFalsy(1); // false

isFalsyExtended:

Made from 'Falsy MDN defenition'.
Also includes Array and object checking.

const { isFalsyExtended } = require("validatees");
isFalsyExtended(1); // false
isFalsyExtended(0); // true
isFalsyExtended([]); // true
isFalsyExtended({}); // true

isTruthy:

Everything not falsy is truthy.
Made from 'Truthy MDN defenition'

const { isTruthy } = require("validatees");
isTruthy(1); // true
isTruthy(0); // false

isTruthyExtended:

Everything not falsy is truthy.
Made from 'Truthy MDN defenition' Also includes Array and object checking.

const { isTruthyExtended } = require("validatees");
isTruthyExtended(1); // true
isTruthyExtended(0); // false
isTruthyExtended([]); // false
isTruthyExtended({}); // false

isNullish:

Check if value is null or undefined.

const { isNullish } = require("validatees");
isNullish(null); // true
isNullish(undefined); // true
isNullish(0); // false

isString:

Check if value is a string.

const { isString } = require("validatees");
isString("string"); // true
isString(1); // false

isNumber:

Check if value is a number.

const { isNumber } = require("validatees");
isNumber(1); // true
isNumber(Infinity); // true
isNumber("string"); // false

Matchers

Matchers are functions that check if a value matches a certain pattern or value.

isSoftMatch:
Check if two values soft match with each other.

const { isSoftMatch } = require("validatees");
isSoftMatch("string", "STRING"); // true
isSoftMatch("string", "abc"); // false
isSoftMatch(1, 1.0); // true

isDeepMatch:
Check if two values deep match with each other.

const { isDeepMatch } = require("validatees");
isDeepMatch({ a: 1 }, { a: 1 }); // true
isDeepMatch({ a: 1 }, { a: 2 }); // false
isDeepMatch([1, 2, { a: 3 }], [1, 2, { a: 3 }]); // true

// without the await it will return a promise holding the boolean.
await isDeepMatch(Promise.resolve(1), Promise.resolve(1)); // true

Contributing

Found a bug🦟? or want to suggest a new feature🆕? or just want to help🆘?

Feel free to open an issue or a pull request.

Contributions are always welcome!🎉

  • Fork the project here.
  • Create a new branch like this: git checkout -b feature/featureName.
  • Commit your changes to your branch: git commit -m 'Create AwesomeFeature'⚙️.
  • Push your branch: git push origin feature/featureName.
  • Open a pull request on the dev branch here🔃.

📒Note: Make sure to add tests for your changes ✅.