{"id":19642673,"url":"https://github.com/k8w/ts-interface-validator","last_synced_at":"2025-04-28T12:32:52.469Z","repository":{"id":57380813,"uuid":"101611322","full_name":"k8w/ts-interface-validator","owner":"k8w","description":"TypeScript interface validator","archived":false,"fork":false,"pushed_at":"2019-01-08T07:53:31.000Z","size":56,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T08:53:26.749Z","etag":null,"topics":["interface","json","json-schema","schema","typescript","validator"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/k8w.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-28T06:31:47.000Z","updated_at":"2023-01-29T09:59:05.000Z","dependencies_parsed_at":"2022-08-27T16:00:42.888Z","dependency_job_id":null,"html_url":"https://github.com/k8w/ts-interface-validator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k8w%2Fts-interface-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k8w%2Fts-interface-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k8w%2Fts-interface-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k8w%2Fts-interface-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k8w","download_url":"https://codeload.github.com/k8w/ts-interface-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251313921,"owners_count":21569520,"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":["interface","json","json-schema","schema","typescript","validator"],"created_at":"2024-11-11T14:14:20.900Z","updated_at":"2025-04-28T12:32:52.464Z","avatar_url":"https://github.com/k8w.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"TypeScript Interface Validator\n---------------------------------\n\n## Intro\n\nA library to validate whether a value is matched a typescript interface definition.\n\nThis is a lightweight and individual implementaion. So only support limited forms of definition.\n\nFor more detail you can see *Supported* and *Not Supported* below.\n\nIf you should have any question, please feel free to let me know.\n\n## Usage\n\n```typescript\nimport ValidatorManager from 'ts-interface-validator';\n\n//Validate from type definition\nlet validator = ValidatorManager.instance.getValidator('{ a: string; b: number[]; c?: \\'C1\\' | \\'C2\\'}');\n//Validate from definition in file\nlet validator2 = ValidatorManager.instance.getValidator('TypeName', 'xxx.ts');\n\n//Validate\nlet result = validator.validate({ a: 'a', b: [2, 'b'] });\nif (result.isSuccess) {\n    //succ\n}\nelse {\n    console.log(result.message, result.originalError.message)\n}\n```\n\n\n\n### Supported pattern\n\n1. Basic type as  `string`, `number`, `boolean`, `Object`, `any`\n1. Array type as `T[]` or `Array\u003cT\u003e`\n1. Type alias as `type Abc = string`\n1. Nested referenced interface, as `type Bcd = Abc`\n1. Logical expression, such as `string | number`\n1. String literal，as `'Value1' | 'Value2'`\n1. Relative import\n1. Extend, as `interface Def extends Abc { ... }`\n1. Index signature, as `{ [key: string]: number }`\n1. Partial type, as `Partial\u003cT\u003e`\n1. Ignore comments automatically\n\n### Not Supported pattern\n\n1. Mapped Types\n1. Circular reference","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk8w%2Fts-interface-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk8w%2Fts-interface-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk8w%2Fts-interface-validator/lists"}