{"id":13624503,"url":"https://github.com/xiscodev/the-type-validator","last_synced_at":"2025-08-08T07:02:40.008Z","repository":{"id":54160918,"uuid":"229400171","full_name":"xiscodev/the-type-validator","owner":"xiscodev","description":"Type validation module for node and browsers.","archived":false,"fork":false,"pushed_at":"2021-03-06T15:19:09.000Z","size":42,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-02T14:58:25.478Z","etag":null,"topics":["javascript","types","validation"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/the-type-validator","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xiscodev.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-21T08:38:46.000Z","updated_at":"2024-07-06T09:05:02.000Z","dependencies_parsed_at":"2022-08-13T08:00:37.255Z","dependency_job_id":null,"html_url":"https://github.com/xiscodev/the-type-validator","commit_stats":null,"previous_names":["deepertech-com/the-type-validator"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/xiscodev/the-type-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiscodev%2Fthe-type-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiscodev%2Fthe-type-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiscodev%2Fthe-type-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiscodev%2Fthe-type-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xiscodev","download_url":"https://codeload.github.com/xiscodev/the-type-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiscodev%2Fthe-type-validator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269379025,"owners_count":24407335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","types","validation"],"created_at":"2024-08-01T21:01:43.239Z","updated_at":"2025-08-08T07:02:39.932Z","avatar_url":"https://github.com/xiscodev.png","language":"JavaScript","funding_links":[],"categories":["javascript"],"sub_categories":[],"readme":"\u003cdiv style=\"display: -ms-flexbox; display: -webkit-flex; display: flex; -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; -webkit-flex-wrap: wrap; -ms-flex-wrap: wrap; flex-wrap: wrap; -webkit-justify-content: center; -ms-flex-pack: center; justify-content: center; -webkit-align-content: center; -ms-flex-line-pack: center; align-content: center; -webkit-align-items: center; -ms-flex-align: center; align-items: center;\"\u003e\n  \u003cimg style=\"-webkit-order: 0; -ms-flex-order: 0; order: 0; -webkit-flex: 0 1 auto; -ms-flex: 0 1 auto; flex: 0 1 auto; -webkit-align-self: auto; -ms-flex-item-align: auto; align-self: auto;\" src=\"icon.png\" /\u003e\n\u003c/div\u003e\n\n\u003ch1 style=\"text-align:center;\"\u003eThe type validator\u003c/h1\u003e\n\n## Why ?\n\nJavascript does not have a pretty way to prove something belongs to a specific type. (Except for Typescript)\n\n* * *\n\nEx1. typeof checking\n\n```js\ntypeof null\n\"object\"\ntypeof undefined\n\"undefined\"\ntypeof \"undefined\"\n\"string\"\ntypeof Object\n\"function\"\ntypeof object\n\"undefined\"\ntypeof {}\n\"object\"\ntypeof true\n\"boolean\"\ntypeof (1 \u003c 2)\n\"boolean\"\ntypeof 1\n\"number\"\ntypeof 0\n\"number\"\n```\n\n* * *\n\nEx2. boolean comparisons\n| Expresion           | Result  |\n\\| -                   \\| -       \\|\n| true == 0           | false   |\n| true == 1           | true    |\n| true == 2           | false   |\n| true == (1 \u0026lt; 2)     | true    |\n| true == \"\"          | false   |\n| true == \"a          | false   |\n| true == {}          | false   |\n| true == !{}         | false   |\n| true == \\[]          | false   |\n| true == !\\[]         | false   |\n| true == null        | false   |\n| true == !null       | true    |\n| true == undefined   | false   |\n| true == !undefined  | true    |\n\n* * *\n\nEx3. conditionals\n\nif blocks or ternaries comparisons result are \"casted\" using [ECMA-262](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf) normative.\n\n```js\n// FALSE goes to else block\nif (0) {\n  //\n}\n\n// TRUE goes to if block\nif (1) {\n  //\n}\n\n// FALSE goes to else block\nif (\"\") {\n  //\n}\n\n// TRUE goes to if block\nif (\"a\") {\n  //\n}\n\n// TRUE goes to if block\nif ({}) {\n  //\n}\n\n// FALSE goes to else block\nif (!{}) {\n  //\n}\n```\n\n**Not as intuitive as you would like.**\n\n* * *\n\n## Which types can be validated\n\n```js\nnull\nundefined\nfunction\n[] // Array\n{} // Object\nPromise\n\"\" // String\n```\n\n## Available methods\n\n-   isNull\n-   isUndefined\n-   isFunction\n-   isString\n-   isNumber\n-   isInteger\n-   isFloat\n-   isArray\n-   isEmptyArray\n-   isObject\n-   isEmptyObject\n-   isPromise\n-   isEmpty\n\n## How to use it?\n\nFirst you need to import it in your project\n\n_The require way_\n\n```js\nlet { isObject } = require(\"the-type-validator\");\n```\n\n_The import way_\n\n```js\nimport { isObject } from \"the-type-validator\";\n```\n\nAll validator methods returns boolean\n\nEx.1 - Checking a null\n\n```js\nconst aNull = null\nconst isVarObject = isObject(aNull)\nconst isVarNull = isNull(aNull)\nconst isVarUndefined = isUndefined(aNull)\n\nconsole.log('isVarObject', isVarObject)\nfalse\nconsole.log('isVarNull', isVarNull)\ntrue\nconsole.log('isVarUndefined', isVarUndefined)\nfalse\n```\n\nEx.2 - Checking an object\n\n```js\nconst anObject = {}\nconst isVarObject = isObject(aNull)\nconst isVarArray = isArray(aNull)\n\nconsole.log('isVarObject', isVarObject)\ntrue\nconsole.log('isVarArray', isVarArray)\nfalse\n```\n\nEx.3 - We can check if object is already empty\n\n```js\nconst isVarObjectAndEmpty = isEmptyObject(anObject)\nconst isVarArrayAndEmpty = isEmptyArray(anObject)\n\nconsole.log('isVarObjectAndEmpty', isVarObjectAndEmpty)\ntrue\nconsole.log('isVarArrayAndEmpty', isVarArrayAndEmpty)\nfalse\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eAdditional JSDOC info\u003c/summary\u003e\n\n### JSDOC\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n##### Table of Contents\n\n-   [isArray](#isarray)\n    -   [Parameters](#parameters)\n-   [isEmptyArray](#isemptyarray)\n    -   [Parameters](#parameters-1)\n-   [isEmpty](#isempty)\n    -   [Parameters](#parameters-2)\n-   [getType](#gettype)\n    -   [Parameters](#parameters-3)\n-   [isNumber](#isnumber)\n    -   [Parameters](#parameters-4)\n-   [isInteger](#isinteger)\n    -   [Parameters](#parameters-5)\n-   [isFloat](#isfloat)\n    -   [Parameters](#parameters-6)\n-   [isObject](#isobject)\n    -   [Parameters](#parameters-7)\n-   [isPlainObject](#isplainobject)\n    -   [Parameters](#parameters-8)\n-   [isEmptyObject](#isemptyobject)\n    -   [Parameters](#parameters-9)\n-   [isNull](#isnull)\n    -   [Parameters](#parameters-10)\n-   [isUndefined](#isundefined)\n    -   [Parameters](#parameters-11)\n-   [isFunction](#isfunction)\n    -   [Parameters](#parameters-12)\n-   [isString](#isstring)\n    -   [Parameters](#parameters-13)\n-   [isPromise](#ispromise)\n    -   [Parameters](#parameters-14)\n\n#### isArray\n\nChecks if data is an array.\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is an array or not\n\n#### isEmptyArray\n\nChecks if data is an empty array.\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is an empty array or not\n\n#### isEmpty\n\nChecks if data is empty, whether is an array or an object.\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is an empty objct or empty array\n\n#### getType\n\nGets data type.\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the type to return\n\n#### isNumber\n\nChecks if data is a number.\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Number or not\n\n#### isInteger\n\nChecks if data is an integer number.\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Integer or not\n\n#### isFloat\n\nChecks if data is a float number.\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Float or not\n\n#### isObject\n\nChecks if data is an object.\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Object or not\n\n#### isPlainObject\n\nChecks if data is a plain object. Borrowing definition as stands in\n\u003chttps://stackoverflow.com/questions/51722354/the-implementation-of-isplainobject-function-in-redux\u003e\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Plain Object or not\n\n#### isEmptyObject\n\nChecks if data is an empty object.\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Empty Object or not\n\n#### isNull\n\nChecks if data is null.\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Null or not\n\n#### isUndefined\n\nChecks if data is undefined.\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Undefined or not\n\n#### isFunction\n\nChecks if data is a function.\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Function or not\n\n#### isString\n\nChecks if data is a string.\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is String or not\n\n#### isPromise\n\nChecks if data is a promise.\n\n##### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Promise or not\n\n### isEmpty\n\nChecks if data is empty, whether is an array or an object.\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is an empty objct or empty array\n\n### getType\n\nGets data type.\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the type to return\n\n### isArray\n\nChecks if data is an array.\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is an array or not\n\n### isEmptyArray\n\nChecks if data is an empty array.\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is an empty array or not\n\n### isNumber\n\nChecks if data is a number.\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Number or not\n\n### isInteger\n\nChecks if data is an integer number.\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Integer or not\n\n### isFloat\n\nChecks if data is a float number.\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Float or not\n\n### isObject\n\nChecks if data is an object.\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Object or not\n\n### isPlainObject\n\nChecks if data is a plain object. Borrowing definition as stands in\n\u003chttps://stackoverflow.com/questions/51722354/the-implementation-of-isplainobject-function-in-redux\u003e\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Plain Object or not\n\n### isEmptyObject\n\nChecks if data is an empty object.\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Empty Object or not\n\n### isNull\n\nChecks if data is null.\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Null or not\n\n### isUndefined\n\nChecks if data is undefined.\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Undefined or not\n\n### isFunction\n\nChecks if data is a function.\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Function or not\n\n### isString\n\nChecks if data is a string.\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is String or not\n\n### isPromise\n\nChecks if data is a promise.\n\n#### Parameters\n\n-   `data` **any** the data to check\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true or false wheter data is Promise or not\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiscodev%2Fthe-type-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiscodev%2Fthe-type-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiscodev%2Fthe-type-validator/lists"}