Skip to content

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

License

Notifications You must be signed in to change notification settings

felipezarco/isness

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 "[email protected]"
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 ([email protected])

License

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published