{"id":26266999,"url":"https://github.com/the-minimal/validator","last_synced_at":"2026-05-18T22:11:15.380Z","repository":{"id":227831909,"uuid":"772499391","full_name":"the-minimal/validator","owner":"the-minimal","description":"Minimal and modular validation library for TypeScript","archived":false,"fork":false,"pushed_at":"2024-07-06T15:04:30.000Z","size":507,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-10-30T04:43:58.482Z","etag":null,"topics":["data-validation","data-validator","javascript","typescript","validation","validator"],"latest_commit_sha":null,"homepage":"https://the-minimal.github.io/validator/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/the-minimal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2024-03-15T10:07:36.000Z","updated_at":"2024-07-06T15:04:33.000Z","dependencies_parsed_at":"2024-03-17T05:25:08.178Z","dependency_job_id":"81aa7735-8ded-4ffe-b5d8-850ced7cd575","html_url":"https://github.com/the-minimal/validator","commit_stats":null,"previous_names":["the-minimal/validator"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-minimal%2Fvalidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-minimal%2Fvalidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-minimal%2Fvalidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-minimal%2Fvalidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/the-minimal","download_url":"https://codeload.github.com/the-minimal/validator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243521218,"owners_count":20304187,"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":["data-validation","data-validator","javascript","typescript","validation","validator"],"created_at":"2025-03-14T04:15:07.744Z","updated_at":"2026-05-18T22:11:10.345Z","avatar_url":"https://github.com/the-minimal.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Validator: A Minimal Data Validation Library\n\nValidator is a highly optimized data validation library designed for simplicity, performance, and ease of use. It aims to meet the needs of developers who require minimal blocking time and low CPU/memory overhead.\n\n## Features\n\n- Data validation only\n-\tSmall learning curve\n-\tMinimal runtime overhead\n-\tTiny bundle size\n-\tTree-shakeable\n-\tStatic type inference\n-\tComposable and modular\n-\t100% Test Coverage\n\n## Opinionated\n\n\u003cdetails open\u003e\n  \u003csummary\u003e\u003cb\u003eNo data transformation\u003c/b\u003e\u003c/summary\u003e\n\n  Focusing solely on data validation allows us to greatly optimize this library.\n\n  I advocate for tools that excel in a single task.\n\n  I believe that, in most cases, we should validate data before performing any transformation.\n\n  This approach simplifies and maintains a clear mental model of what data validation is and how it should be implemented in our applications.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eNo asynchronous validations\u003c/b\u003e\u003c/summary\u003e\n\n  JSON data types do not require asynchronous validation.\n\n  Avoid introducing side effects within validations.\n\n  Don't do this:\n\n  ```ts\n  // definition\n  const validate = and([\n    string,\n    minLength(5),\n    async (v) =\u003e {\n      if(!(await File.exists(v))) {\n        throw Error(\"File does not exist\");\n      }\n    }\n  ]);\n\n  // endpoint\n  await assert(validate, filename);\n  ```\n\n  Do this instead:\n\n  ```ts\n  // definition\n  const validate = and([\n    string,\n    minLength(5),\n  ]);\n\n  // endpoint\n  assert(validate, filename);\n\n  if(!(await File.exists(filename))) {\n    throw Error(\"File does not exist\");\n  }\n  ```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eNo compilation or eval\u003c/b\u003e\u003c/summary\u003e\n\n  Compilation with `Function`/`eval` syntax is not allowed in all environments and, more importantly, it would mean maintaining two different runtime implementations, which I do not want.\n\n  It also sacrifices initial blocking for faster subsequent runs, which might be useful in some scenarios. However, this library is primarily designed for serverless runtimes, where this would result in drastically slower performance.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eNo methods like \u003ccode\u003eextend\u003c/code\u003e/\u003ccode\u003eomit\u003c/code\u003e\u003c/b\u003e\u003c/summary\u003e\n\n  In order to allow such methods, we would have to make the schema accessible from the outside.\n\n  This would change the design from using individual callable validations to using objects with properties, one of which is the validation.\n\n  Additionally, this would make it possible, for example, to extend any object, even if we don't want users to have such capability.\n\n  To address this issue, we would need to introduce some form of object schema freezing.\n\n  All of this complicates the API, slows down the library, and increases the bundle size.\n\n  You can make an object extendable by exporting its schema separately and then spreading it inside another schema.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eNo validations like \u003ccode\u003emap\u003c/code\u003e/\u003ccode\u003eset\u003c/code\u003e\u003c/b\u003e\u003c/summary\u003e\n\n  The main focus of this library is the data validation of JSON (primarily from fetch requests).\n\n  JSON does not support these data types, so it makes no sense to include them in this library.\n\n  If you want to use this library with these higher-level primitives, then I recommend validating the input of these primitives.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eNo validations like \u003ccode\u003eany\u003c/code\u003e/\u003ccode\u003eunknown\u003c/code\u003e\u003c/b\u003e\u003c/summary\u003e\n\n  You should always define concrete types.\n\n  Otherwise, what's the point of using TypeScript together with this library?\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eNo validations like \u003ccode\u003enull\u003c/code\u003e/\u003ccode\u003eundefined\u003c/code\u003e\u003c/b\u003e\u003c/summary\u003e\n\n  Checking strictly for `null` or `undefined` alone makes no sense.\n\n  You always want to know if something can be _something_ or _nothing_.\n\n  Therefore, you should always use `nullable`, `optional`, or `nullish` instead.\n\n\u003c/details\u003e\n\n## Performance Metrics\n\nValidator is engineered to deliver exceptional performance:\n\n- **Bundle Size**: 835 bytes (minified and gzipped)\n-\t**Speed**: Approximately 5x faster than Zod for data validation\n-\t**Memory Usage**: Approximately 200x less memory consumption than Zod\n-\t**Type-checking**: Approximately 50x faster than Zod\n-\t**Dependencies**: Only one in-house dependency\n-\t**Test Coverage**: 100%\n\n## Usage Examples\n\n### Validating Types\n\n```ts\nassert(string, \"Hello, World!\");\nassert(number, 420);\nassert(boolean, true);\n```\n\n### Validating Values\n\n```ts\nvalue(26);\nnotValue(0);\nminValue(18);\nmaxValue(100);\nrangeValue(18, 100);\n```\n\n### Validating Lengths\n\n```ts\nlength(5);\nnotLength(0);\nminLength(8);\nmaxLength(16);\nrangeLength(8, 16);\n```\n\n### Combining Validations\n\n```ts\nconst register = object({\n  email: and([string, rangeLength(5, 35), email]),\n  password: and([string, rangeLength(8, 16)]),\n  role: union([\"ADMIN\", \"USER\"]),\n  friends: array(string)\n});\n\nassert(\n  register,\n  {\n    email: \"yamiteru@icloud.com\",\n    password: \"Test123456\",\n    role: \"ADMIN\",\n    friends: [\"Joe\"]\n  }\n);\n```\n\n## Installation\n\n```bash\nyarn add @the-minimal/validator\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-minimal%2Fvalidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthe-minimal%2Fvalidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-minimal%2Fvalidator/lists"}