CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-is-js

Micro check library providing comprehensive type checking and validation operations across different JavaScript environments

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

pattern-matching.mddocs/

Pattern Matching

Regular expression-based validation for common data formats including emails, URLs, phone numbers, and postal codes.

Capabilities

Email Validation

Checks if the given value matches email format.

/**
 * Checks if the given value matches email regexp
 * @param value - Value to check
 * @returns True if value matches email format
 * Interfaces: not, all, any
 */
function email(value: any): boolean;

Usage Example:

is.email('test@test.com');     // true
is.email('foo');               // false
is.not.email('foo');           // true
is.all.email('test@test.com', 'foo'); // false
is.any.email('test@test.com', 'foo'); // true

URL Validation

Checks if the given value matches URL format.

/**
 * Checks if the given value matches url regexp
 * @param value - Value to check
 * @returns True if value matches URL format
 * Interfaces: not, all, any
 */
function url(value: any): boolean;

Usage Example:

is.url('http://www.test.com'); // true
is.url('foo');                 // false
is.not.url(true);              // true
is.all.url('http://www.test.com', 'foo'); // false
is.any.url('http://www.test.com', true); // true

Credit Card Validation

Checks if the given value matches credit card number format.

/**
 * Checks if the given value matches credit card regexp
 * @param value - Value to check
 * @returns True if value matches credit card format
 * Interfaces: not, all, any
 */
function creditCard(value: any): boolean;

Usage Example:

is.creditCard(378282246310005); // true
is.creditCard(123);             // false
is.not.creditCard(123);         // true
is.all.creditCard(378282246310005, 123); // false
is.any.creditCard(378282246310005, 123); // true

Alphanumeric Validation

Checks if the given value matches alphanumeric format.

/**
 * Checks if the given value matches alpha numeric regexp
 * @param value - Value to check
 * @returns True if value contains only letters and numbers
 * Interfaces: not, all, any
 */
function alphaNumeric(value: any): boolean;

Usage Example:

is.alphaNumeric('alphaNu3er1k'); // true
is.alphaNumeric('*?');           // false
is.not.alphaNumeric('*?');       // true
is.all.alphaNumeric('alphaNu3er1k', '*?'); // false
is.any.alphaNumeric('alphaNu3er1k', '*?'); // true

Date String Validation

Checks if the given value matches date string format (m/d/yy and mm/dd/yyyy).

/**
 * Checks if the given value matches date string regexp
 * @param value - Value to check
 * @returns True if value matches date string format
 * Interfaces: not, all, any
 */
function dateString(value: any): boolean;

Usage Example:

is.dateString('11/11/2011');    // true
is.dateString('10-21-2012');    // true
is.dateString('90/11/2011');    // false
is.not.dateString('90/11/2011'); // true
is.all.dateString('11/11/2011', '90/11/2011'); // false
is.any.dateString('11-11-2011', '90/11/2011'); // true

Time String Validation

Checks if the given value matches time string format (HH:MM:SS).

/**
 * Checks if the given value matches time string regexp
 * @param value - Value to check
 * @returns True if value matches time format
 * Interfaces: not, all, any
 */
function timeString(value: any): boolean;

Usage Example:

is.timeString('13:45:30');      // true
is.timeString('90:90:90');      // false
is.not.timeString('90:90:90');  // true
is.all.timeString('13:45:30', '90:90:90'); // false
is.any.timeString('13:45:30', '90:90:90'); // true

IP Address Validation

Checks if the given value matches IP address format (IPv4 or IPv6).

/**
 * Checks if the given value matches ip regexp
 * @param value - Value to check
 * @returns True if value matches IPv4 or IPv6 format
 * Interfaces: not, all, any
 */
function ip(value: any): boolean;

/**
 * Checks if the given value matches ipv4 regexp
 * @param value - Value to check
 * @returns True if value matches IPv4 format
 * Interfaces: not, all, any
 */
function ipv4(value: any): boolean;

/**
 * Checks if the given value matches ipv6 regexp
 * @param value - Value to check
 * @returns True if value matches IPv6 format
 * Interfaces: not, all, any
 */
function ipv6(value: any): boolean;

Usage Example:

is.ip('198.156.23.5');          // true
is.ip('2001:DB8:0:0:1::1');     // true
is.ipv4('198.12.3.142');        // true
is.ipv6('2001:DB8:0:0:1::1');   // true
is.not.ip('8:::::::7');         // true

Phone Number Validation

Checks if the given value matches phone number formats.

/**
 * Checks if the given value matches North American numbering plan phone regexp
 * @param value - Value to check
 * @returns True if value matches NANP phone format
 * Interfaces: not, all, any
 */
function nanpPhone(value: any): boolean;

/**
 * Checks if the given value matches extensible provisioning protocol phone regexp
 * @param value - Value to check
 * @returns True if value matches EPP phone format
 * Interfaces: not, all, any
 */
function eppPhone(value: any): boolean;

Usage Example:

is.nanpPhone('609-555-0175');   // true
is.eppPhone('+90.2322456789');  // true
is.nanpPhone('123');            // false
is.not.nanpPhone('123');        // true

Postal Code Validation

Checks if the given value matches postal code formats for different countries.

/**
 * Checks if the given value matches US zip code regexp
 * @param value - Value to check
 * @returns True if value matches US ZIP code format
 * Interfaces: not, all, any
 */
function usZipCode(value: any): boolean;

/**
 * Checks if the given value matches Canada postal code regexp
 * @param value - Value to check
 * @returns True if value matches Canadian postal code format
 * Interfaces: not, all, any
 */
function caPostalCode(value: any): boolean;

/**
 * Checks if the given value matches UK post code regexp
 * @param value - Value to check
 * @returns True if value matches UK postal code format
 * Interfaces: not, all, any
 */
function ukPostCode(value: any): boolean;

Usage Example:

is.usZipCode('02201-1020');     // true
is.caPostalCode('L8V3Y1');      // true
is.caPostalCode('L8V 3Y1');     // true
is.ukPostCode('B184BJ');        // true

Social Security Number Validation

Checks if the given value matches US Social Security Number format.

/**
 * Checks if the given value matches social security number regexp
 * @param value - Value to check
 * @returns True if value matches SSN format
 * Interfaces: not, all, any
 */
function socialSecurityNumber(value: any): boolean;

Usage Example:

is.socialSecurityNumber('017-90-7890'); // true
is.socialSecurityNumber('017907890');   // true
is.socialSecurityNumber('123');         // false
is.not.socialSecurityNumber('123');     // true

Hexadecimal and Color Validation

Checks if the given value matches hexadecimal or color formats.

/**
 * Checks if the given value matches hexadecimal regexp
 * @param value - Value to check
 * @returns True if value is hexadecimal
 * Interfaces: not, all, any
 */
function hexadecimal(value: any): boolean;

/**
 * Checks if the given value matches hexcolor regexp
 * @param value - Value to check
 * @returns True if value is hex color code
 * Interfaces: not, all, any
 */
function hexColor(value: any): boolean;

Usage Example:

is.hexadecimal('f0f0f0');       // true
is.hexadecimal('0xf0f0f0');     // true
is.hexColor('#333');            // true
is.hexColor('#3333');           // false
is.all.hexColor('fff', 'f50');  // true

Affirmative Response Validation

Checks if the given value matches affirmative response patterns.

/**
 * Checks if the given value matches affirmative regexp
 * @param value - Value to check
 * @returns True if value is affirmative (yes, true, ok, etc.)
 * Interfaces: not, all, any
 */
function affirmative(value: any): boolean;

Usage Example:

is.affirmative('yes');          // true
is.affirmative('true');         // true
is.affirmative('ok');           // true
is.affirmative('no');           // false
is.not.affirmative('no');       // true
is.all.affirmative(['yes', 'y', 'true', 't', 'ok', 'okay']); // true

docs

collection-validation.md

configuration.md

date-time.md

environment-detection.md

index.md

numeric-operations.md

pattern-matching.md

presence-checking.md

string-checking.md

type-checking.md

tile.json