All Projects → joeltankam → checkif.js

joeltankam / checkif.js

Licence: MIT license
Javascript check library

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to checkif.js

connection checker
Android library for checking the internet connectivity of a device.
Stars: ✭ 26 (-13.33%)
Mutual labels:  verify, check
is-primitive
Is the typeof value a javascript primitive?
Stars: ✭ 35 (+16.67%)
Mutual labels:  is, check
Directorylister
📂 Directory Lister is the easiest way to expose the contents of any web-accessible folder for browsing and sharing.
Stars: ✭ 1,261 (+4103.33%)
Mutual labels:  verify
private-ip
Check if IP address is private.
Stars: ✭ 26 (-13.33%)
Mutual labels:  check
Strsync
A CLI tool for localization resource management on Xcode. Built with Google Translator.
Stars: ✭ 157 (+423.33%)
Mutual labels:  verify
Piracychecker
An Android library that prevents your app from being pirated / cracked using Google Play Licensing (LVL), APK signature protection and more. API 14+ required.
Stars: ✭ 1,359 (+4430%)
Mutual labels:  verify
Vuejs Rails Starterkit
Vue.js + Rails Starting Kit GitHub Template to develop Hybrid Mobile Application: https://vuejs-rails-starterkit.herokuapp.com
Stars: ✭ 205 (+583.33%)
Mutual labels:  verify
Vonage Java Sdk
Vonage Server SDK for Java. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Stars: ✭ 75 (+150%)
Mutual labels:  verify
form-bunch
Form-bunch is a component like plugin that make it easier to write form, you could add the most of components what you want to form-bunch for build various form.
Stars: ✭ 18 (-40%)
Mutual labels:  verify
Immudb
immudb - world’s fastest immutable database, built on a zero trust model
Stars: ✭ 3,743 (+12376.67%)
Mutual labels:  verify
url-survival-check
批量检测URL存活
Stars: ✭ 44 (+46.67%)
Mutual labels:  check
Elm Verify Examples
Stars: ✭ 147 (+390%)
Mutual labels:  verify
Signify
OpenBSD tool to signs and verify signatures on files. Portable version.
Stars: ✭ 122 (+306.67%)
Mutual labels:  verify
pgpverify-maven-plugin
Verify Open PGP / GPG signatures plugin
Stars: ✭ 42 (+40%)
Mutual labels:  verify
Qa Checks V4
PowerShell scripts to ensure consistent and reliable build quality and configuration for your servers
Stars: ✭ 94 (+213.33%)
Mutual labels:  verify
discord-group-spammer
You need to run all_together.py and follow the instructions on the readme below. This Tool allows you to use various discord exploits for educational use.
Stars: ✭ 45 (+50%)
Mutual labels:  verify
Is Google
Verify that a request is from Google crawlers using Google's DNS verification steps
Stars: ✭ 82 (+173.33%)
Mutual labels:  verify
Paseto
PASETO (Platform-Agnostic SEcurity TOkens) for Node.js with no dependencies
Stars: ✭ 134 (+346.67%)
Mutual labels:  verify
Android Play Safetynet
Samples for the Google SafetyNet Attestation API
Stars: ✭ 195 (+550%)
Mutual labels:  verify
has-value
Returns true if a value exists, false if empty. Works with deeply nested values using object paths.
Stars: ✭ 27 (-10%)
Mutual labels:  check

checkif.js

This library aims to perform various checks in the javascript environment.

Build Status Codacy Badge Codacy Badge npm version slack checkif.js

Installation

checkif.js is distributed as a npm package.

npm install checkif.js

Documentation

The library is constituted of a set of checkers to perform different verifications.

is

import { is } from 'checkif.js';

Types

This group of methods allows to verify if a given value is from a specific type.

null(value)

Checks if a given value is null.

undefined(value)

Alias und(value)

Checks if a given value is undefined.

nullable(value)

Checks if a given value is null or undefined.

nan(value)

Checks if a given value is NaN. Same as Number.isNaN.

is.nan(NaN); // true
is.nan(Number.NaN); // true
array(value)

Alias arr(value)

Checks if a given value is an array. This method is the same as Array.isArray, if available.

is.array([]); // true
is.array(new Array(0)); // true
boolean(value)

Alias bool(value)

Checks if a given value is a boolean.

is.boolean(true); // true
is.boolean(new Boolean(0)); // true
string(value)

Alias str(value)

Checks if a given value is a string.

is.string(''); // true
is.string(String('')); // true
is.string(new String('')); // true
char(value)

Checks if a given value is a char.

is.char(' '); // true
is.char('1'); // true
is.char(1); // false
date(value)

Checks if a given value is a date.

is.date(new Date('November 23, 1998 03:24:00')); // true, my birthdate btw ;)
number(value)

Alias num(value)

Checks if a given value is a number.

is.number(Number(1)); // true
is.number(new Number(1)); // true
is.number(1); // true
regexp(value)

Alias reg(value)

Checks if a given value is a regular expression.

is.regexp(\a\); // true
is.regexp(RegExp()); // true
is.regexp(new RegExp()); // true
object(value)

Alias obj(value)

Checks if a given value is an object.

is.object({}); // true
is.object(String(1)); // true
is.object('1'); // false
pureObject(value)

Alias pure(value)

Checks if a given value is a pure JSON object.

is.pureObject({}); // true
is.pureObject({ value: 1 }); // true
is.pureObject(new Date()); // false
function(value)

Alias func(value)

Checks if a given value is a function.

is.function(function () { }); // true
is.function(x => x); // true
is.function(new Function('x', 'return x')); // true
error(value)

Alias err(value)

Checks if a given value is an error.

is.error(Error('Fatal error')); // true
is.error(new Error('Nothing works anymore')); // true
domNode(value)

Alias dom(value)

Checks if a given value is a DOM node.

// Browser
is.domNode(window.document.body); // true
// Node.js
let dom = new JSDOM(`<html !DOCTYPE><body></body></html>`);
is.domNode(dom.window.document.body); // true
windowObject(value)

Alias window(value)

Checks if a given value is a window object.

// Browser
is.windowObject(window); // true
// Node.js
let dom = new JSDOM(`<html !DOCTYPE></html>`)
is.windowObject(dom.window); // true

RegExp

This group of methods allows to verify if a given string is from a specific known type of value.

To be implemented

String

This group of methods allows to verify if a given string is a from a specific format.

lowerCase(value)

Check if a given string is lower case.

is.lowerCase('abc'); // true
is.lowerCase('abc 123'); // true
is.lowerCase('ABC'); // false
upperCase(value)

Check if a given string is upper case.

is.upperCase('ABC'); // true
is.upperCase('ABC 123'); // true
is.upperCase('abc'); // false

Arithmetic

This group of methods allows to verify if a given number is a from a specific class of numbers.

even(value)

Checks if a given value is even.

is.even(10); // true
is.even(11); // false
odd(value)

Checks if a given value is odd.

is.odd(9); // true
is.odd(10); // false
integer(value)

Alias int(value)

Checks if a given value is an integer.

is.integer(12); // true
is.integer(10.0); // true
is.integer(3.14); // false
is.integer(Number.MIN_VALUE); // false
is.integer(Infinity); // false
is.integer('6');// false

Environment

This group of methods allows to verify if the current environment is a specific environment.

To be implemented

Time

This group of methods allows to verify if a date is a specific kind.

past(value)

Checks if a given value is a Date object in the past.

is.past(new Date(0)); // true

let pastDate = new Date();
pastDate.setUTCFullYear(pastDate.getUTCFullYear() - 1);
is.past(pastDate); // true

let futureDate = new Date();
futureDate.setUTCFullYear(futureDate.getUTCFullYear() + 1);
is.past(futureDate); // false
future(value)

Checks if a given value is a Date object in the future.

let futureDate = new Date();
futureDate.setUTCFullYear(futureDate.getUTCFullYear() + 1);
is.future(futureDate); // true

is.future(new Date(0)); // false

let pastDate = new Date();
pastDate.setUTCFullYear(pastDate.getUTCFullYear() - 1);
is.future(pastDate); // false
today(value)

Checks if a given value is a Date object set today.

let date = new Date();
date.setUTCHours(12);
date.setUTCMinutes(30);

is.today(date); // true
is.today(new Date()); // true
is.today(new Date(0)); // false

let pastDate = new Date();
pastDate.setUTCFullYear(pastDate.getUTCFullYear() - 1);
is.today(pastDate); // false

let futureDate = new Date();
futureDate.setUTCFullYear(futureDate.getUTCFullYear() + 1);
is.today(futureDate); // false

all

all(enumerable, matcher, strict = false)

import { all } from 'checkif.js';

This method verifies if all elements in a given enumerable (array or object) match a specific value or function.

all on arrays

all([0, 0, 0, 0], 0); // true
all([2, 4, 6, 8], x => x%2 === 0); // true

all([0, 1, 2, 3], 1); // false

all on objects

all({ x: 1, y: 1 }, 1); // true
let a = {};
all({ x: a, y: a }, x => x === a); // true

all({ x: 0, y: new Number(0) }, function(x){ return x === 0; }); // false

Strict mode

The second parameter of all is automatically resolved as a matcher function when it's a function. But you may want to check if the values are exactly equal to the function (as a value). In this case, you should use the strict mode by setting the 3rd parameter to true (default false).

import { all } from 'checkif.js';

let _function = function (x) { ... };
all({ x: _function, y: _function }, _function, true); // true

Feel free to build complex logic for your checks.

import { all, is } from 'checkif.js';
all({ x: ['a', 'b'], y: ['a', 'c'] }, x => all(x, is.char)); // true

any

any(enumerable, matcher, strict = false)

This method verifies if any element in a given enumerable (array or object) matches a specific value or function.

import { any } from 'checkif.js';

any([0,1,2,3], 2); // true
any([0,1,2,3], x => x === 0); // true
any({ x : 1, y : 0}, x => x === 1); // true

any([0, 1, 2, 3], 1); // false
any({ x : 1, y : 1}, 2); // false
any([0,1,2,3], x => x === 5); //false

any also supports strict mode.

has

This group of methods allows to verify if a given enumerable (array or object) has an element verifying a specific condition. This checker contains the same methods as is. In fact, has.method(array) is equivalent to any(array, is.method).

import { any } from 'checkif.js';

has.uppercase(['abc', 'Abc', 'ABC']); // true
has.even({ x : 1, y : 2, z : 3}); // true
has.function({ x : function(){}}); // true

has.nan([0, 1, 2, 3]); // false
has.integer([1.2, 1.3]); // false
has.null([]); // false

hasOnly

This group of methods allows to verify if a given enumerable (array or object) has only elements verifying a specific condition. This checker contains the same methods as is.

hasOnly.method(array) is equivalent to all(array, is.method).

import { any } from 'checkif.js';

hasOnly.lowercase(['abc', 'def', 'ghi']); // true
hasOnly.integer({ x : 1, y : 2, z : 3}); // true
hasOnly.function({ x : function(){}, y : x => x}); // true

hasOnly.null([null, 1, 2, 3]); // false
hasOnly.odd([1, 2, 3]); // false

atLeast

atLeast(enumerable, count, matcher, strict = false)

Alias atl(enumerable, count, matcher, strict = false)

This method verifies if at least a number of elements in a given enumerable (array or object) match a specific value or function.

import { atLeast } from 'checkif.js';

atLeast([1,1,2,3], 2, 1); // true
atLeast([0,0,2,0], 3, x => x === 0); // true
atLeast({ x : 1, y : 0}, 1, x => x === 1); // true

atLeast([0, 1, 2, 3], 2, 1); // false
atLeast({ x : 1, y : 1}, 3, 2); // false
atLeast([0,1,2,3], 1, x => x === 5); //false

atLeast also supports strict mode.

atMost

atMost(enumerable, count, matcher, strict = false)

Alias atm(enumerable, count, matcher, strict = false)

This method verifies if at most a number of elements in a given enumerable (array or object) match a specific value or function.

import { atMost } from 'checkif.js';

atMost([0, 0, 1, 2], 2, 0); // true
atMost([true, true, true, false], 3, x => x === true); // true
atMost({ x: a, y: a }, 3, x => x === a); // true

atMost([0, 0, 1, 1], 1, 0); // false
atMost({ x: 1, y: 0 }, 0, 1); // false
let _function = function () { return true };
atMost({ x: _function, y: _function }, 1, _function); // false

atMost also supports strict mode.

hasAtLeast

hasAtLeast(count)

This group of methods allows to verify if a given enumerable (array or object) has at least a number of elements verifying a specific condition from is. hasAtLeast(count).method(enumerable) is equivalent to atLeast(enumerable, count, is.method).

hasAtMost

hasAtMost(count)

This group of methods allows to verify if a given enumerable (array or object) has at most a number of elements verifying a specific condition from is. hasAtMost(count).method(enumerable) is equivalent to atMost(enumerable, count, is.method).

Keep in mind that using the has* notation is less performant than using the equivalent atLeast or atMost function. Everytime has*(count) is called, the resulting functions are regenerated from is.

Contributing

Any help is wanted and welcome. You can check out our github issues and projects or our slack page.

Please follow our contributing guidelines.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].