Skip to main content
Home

@zarco/isness@0.1.18
Built and signed on GitHub Actions

A simple library to check if a value is what you expect it to be.

This package works with Node.js, DenoIt is unknown whether this package works with Cloudflare Workers, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
100%
Published
11 months ago (0.1.18)

A simple library to check if a value is what you expect it to be.

Usage

Install

Node:

npx jsr add @zarco/isness

Deno:

import is from "jsr:@zarco/isness"

Usage

import * as is from "@zarco/isness";

if (is.string("hello")) {
  // do something
}

Methods

The tables below show the methods available in the package, divided by category. Each example consists of one or more values that evaluate to true for the method.

Character

The following methods check if a string is composed of a specific set of characters.

Method Description Example
alphabetic Checks if a string is alphabetic "abc"
alphanumeric Checks if the given string consists only of alphanumeric characters "abc123"
ascii Checks if a string is ascii "abc123"
digit Checks if a string is a digit "3"
hexadecimal Checks if a string is hexadecimal "a1b2c3"
lowercase Checks if a string is lowercase "abc"
uppercase Checks if a string is uppercase "ABC"
whitespace Checks if a string is a whitespace " "

Type

The following methods check if a value is of a specific type.

Method Description Example
array Checks if a value is an array [1, 2, 3]
string Checks if a value is a string "hello"
boolean Checks if a value is a boolean true
booleanLike Checks if a value is boolean-like true, "true" or 1
number Checks if a value is a number 123, 3.14, "123", 0
objectId Checks if a value is an ObjectId "507f1f77bcf86cd799439011"
string Checks if a value is a string "hello", ""

Temporal

The following are the date/time related methods.

Method Description Example
date Checks if a value is a date new Date(), "2021-01-01"

Identifier

The following are the unique identificator methods

Method Description Example
domain Checks if a value is a domain name "example.com"
email Checks if a value is an email "felipezarco@hotmail.com"
url Checks if a value is an URL "https://github.com/felipezarco"

Person

Method Description Example
name Checks if a value is a name "Zarco"
fullName Checks if a value is a full name "Luiz Felipe Zarco"
cpf Checks if a value is a CPF "123.456.789-09"
cnpj Checks if a value is a CNPJ "12.345.678/0001-01"
cellphone Checks if a value is a phone "+55 11 1234-5678"

More details about each method can be found in the API documentation.

Contributing

If you would like to contribute to this package you can (and should) open an issue and/or submit your own pull request.

Thanks for your interest in contributing to this repo!

Author

Luiz Felipe Zarco (felipezarco@hotmail.com)

License

This code is licensed under the MIT License. See the LICENSE file for more info.

Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@zarco/isness

Import symbol

import * as isness from "@zarco/isness";
or

Import directly with a jsr specifier

import * as isness from "jsr:@zarco/isness";

Add Package

pnpm i jsr:@zarco/isness
or (using pnpm 10.8 or older)
pnpm dlx jsr add @zarco/isness

Import symbol

import * as isness from "@zarco/isness";

Add Package

yarn add jsr:@zarco/isness
or (using Yarn 4.8 or older)
yarn dlx jsr add @zarco/isness

Import symbol

import * as isness from "@zarco/isness";

Add Package

vlt install jsr:@zarco/isness

Import symbol

import * as isness from "@zarco/isness";

Add Package

npx jsr add @zarco/isness

Import symbol

import * as isness from "@zarco/isness";

Add Package

bunx jsr add @zarco/isness

Import symbol

import * as isness from "@zarco/isness";