{"id":29623763,"url":"https://github.com/mikemitterer/ts-validate","last_synced_at":"2025-07-21T05:07:54.720Z","repository":{"id":142151370,"uuid":"175000722","full_name":"MikeMitterer/ts-validate","owner":"MikeMitterer","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-02T03:20:09.000Z","size":1623,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-16T06:44:43.838Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MikeMitterer.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-11T12:59:41.000Z","updated_at":"2024-09-02T03:20:12.000Z","dependencies_parsed_at":"2024-08-21T09:47:40.991Z","dependency_job_id":"88591064-c224-47d3-8224-99b8e3f0d1d0","html_url":"https://github.com/MikeMitterer/ts-validate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MikeMitterer/ts-validate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeMitterer%2Fts-validate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeMitterer%2Fts-validate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeMitterer%2Fts-validate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeMitterer%2Fts-validate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MikeMitterer","download_url":"https://codeload.github.com/MikeMitterer/ts-validate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeMitterer%2Fts-validate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266242072,"owners_count":23898102,"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","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":[],"created_at":"2025-07-21T05:07:53.932Z","updated_at":"2025-07-21T05:07:54.708Z","avatar_url":"https://github.com/MikeMitterer.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Validate\n\u003e Lightweight TS library for validating function arguments.\n\n## Installation\n\n    npm i @mmit/validate\n    yarn add @mmit/validate\n\n# API changed v 0.3.0\nThe return value of the following functions changed from **boolean** to **string**:\n\n      isPassword\n      isAlphanumeric\n      isHex\n      isUuid\n      isUrl\n      isEmail\n      isHostname\n      matchesPattern\n\n`isIndexValid` returns now the validated **array value** instead of the array index      \n\n## Usage\n\n```typescript\nimport * as validate from '@mmit/validate';\n\nvalidate.isHex('1234567890abcdef');\n\n// This throws an ArgumentError with \"'1234567890abcdefg' is not a hex value\"\nvalidate.isHex('1234567890abcdefg');\n\n// The same but with your custom error message\nvalidate.isHex('1234567890abcdefg', () =\u003e 'My custom message');\n\ntype MyName = string | undefined;\n\nconst sayMyName = (name: MyName): MyName =\u003e name;\n\n// This would lead to: \"Type 'string | undefined' is not assignable\n// to type 'string'\n// const checkedName = (name: MyName): string =\u003e sayMyName(name);\n\n// Checked version strips out \"undefined\"\nconst checkedName = (name: MyName): string =\u003e validate.notNull(sayMyName(name));\n\nexpect(checkedName(\"Mike\")).toBe(\"Mike\");\nexpect(() =\u003e checkedName(undefined)).toThrow(ArgumentError);\n```\n\nFor more examples - pls check out my [Tests](https://github.com/MikeMitterer/ts-validate/tree/master/src/test/unit/validate)\n\n## Bugs / Contribute\n\nYou reach me via [GH - Issues](https://github.com/MikeMitterer/ts-validate/issues)\n\nHelp is always welcome!\n\n## License\n\n    MIT License\n\n    Copyright (c) 2019, Mike Mitterer \u003coffice@mikemitterer.at\u003e\n\n    Mike Mitterer: http://www.MikeMitterer.at/\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in all\n    copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n    SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikemitterer%2Fts-validate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikemitterer%2Fts-validate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikemitterer%2Fts-validate/lists"}