Package Exports
- validatees
- validatees/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (validatees) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
validatees
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 β .