@defriction/is_a

Utility for detecting value types

Usage no npm install needed!

<script type="module">
  import defrictionIsA from 'https://cdn.skypack.dev/@defriction/is_a';
</script>

README

is_a

Utility function to help determine value types

`is_a` is for the most part a collection of frequently used regex patterns to determine value types.

Installation

npm install @defriction/is_a

Example usage

import is_a from '@defriction/is_a';
// ... 

if( is_a('email', 'foobar@foo.com') ){
    console.log('This is a valid email address!');
}else{
    console.log('This email addres is not valid!');
}

Value Check Types

  • Email is_a('email', value);
  • Email Charactersis_a('email_character', value);
  • Domain is_a('domain', value);
  • Domain Characters is_a('domain_character', value);
  • URL is_a('url', value);
  • Phone is_a('phone', value); // +1(555) 555-5555 and 555.555.5555 and 555-555-5555 are true
  • Strong Password is_a('strong_password', value); // Min 8 characters, Uppercase letter, Lowercase Letter, Special Character (@$!%*?&)
  • Truthy is_a('truthy', value);
  • Falsy is_a('falsy', value);
  • String is_a('string', value);
  • Number is_a('number', value); // false against NaN