{"id":18348649,"url":"https://github.com/averagehelper/hono-superstruct-validator","last_synced_at":"2025-04-09T23:28:43.192Z","repository":{"id":195613646,"uuid":"693325934","full_name":"AverageHelper/hono-superstruct-validator","owner":"AverageHelper","description":"Hono validator middleware using Superstruct. (Read-only Git mirror)","archived":false,"fork":false,"pushed_at":"2023-12-17T04:59:16.000Z","size":361,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T00:17:43.919Z","etag":null,"topics":["mirror"],"latest_commit_sha":null,"homepage":"https://git.average.name/AverageHelper/hono-superstruct-validator","language":"TypeScript","has_issues":false,"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/AverageHelper.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":"FUNDING.yml","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},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"https://average.name/support"}},"created_at":"2023-09-18T19:58:34.000Z","updated_at":"2023-12-14T18:18:25.000Z","dependencies_parsed_at":"2023-09-19T00:00:10.889Z","dependency_job_id":"be5466d3-25ed-4735-aa47-8d7f40adf71a","html_url":"https://github.com/AverageHelper/hono-superstruct-validator","commit_stats":null,"previous_names":["averagehelper/hono-superstruct-validator"],"tags_count":13,"template":false,"template_full_name":"AverageHelper/node-project-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AverageHelper%2Fhono-superstruct-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AverageHelper%2Fhono-superstruct-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AverageHelper%2Fhono-superstruct-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AverageHelper%2Fhono-superstruct-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AverageHelper","download_url":"https://codeload.github.com/AverageHelper/hono-superstruct-validator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248128667,"owners_count":21052442,"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":["mirror"],"created_at":"2024-11-05T21:18:41.917Z","updated_at":"2025-04-09T23:28:43.159Z","avatar_url":"https://github.com/AverageHelper.png","language":"TypeScript","funding_links":["https://average.name/support"],"categories":[],"sub_categories":[],"readme":"# Superstruct validator middleware for Hono\n\nValidator middleware using [Superstruct](https://docs.superstructjs.org) for [Hono](https://honojs.dev) applications.\n\nYou can write a schema with Superstruct and validate the incoming values.\n\n## Usage\n\n```ts\nimport { number, object, string } from \"superstruct\";\nimport { sValidator } from \"hono-superstruct-validator\";\n\nconst schema = object({\n\tname: string(),\n\tage: number()\n});\n\napp.post(\"/author\", sValidator(\"json\", schema), c =\u003e {\n\tconst data = c.req.valid(\"json\");\n\treturn c.json({\n\t\tsuccess: true,\n\t\tmessage: `${data.name} is ${data.age}`\n\t});\n});\n```\n\nBy default, if the incoming data does not match the given schema, a JSON object will be returned to the caller, with a status of 400. The response will have the following interface:\n\n```ts\ninterface ResponseBody {\n\tmessage: string;\n}\n```\n\nThe message will, by default, be the `message` property of the relevant `StructError`.\n\nIf you wish to handle errors differently, you may include a callback function:\n\n```ts\napp.post(\n\t\"/post\",\n\tsValidator(\"json\", schema, (result, c) =\u003e {\n\t\treturn c.text(\"Invalid!\", 400);\n\t})\n\t//...\n);\n```\n\nAt the moment, there is no opportunity to recover from the error. If the input data is bad, the middleware _will_ fail out and respond to the caller.\n\n## Author\n\nAverage Helper \u003chttps://git.average.name/AverageHelper\u003e\n\nMuch of this work is based on [Yusuke Wada](https://github.com/yusukebe)'s wonderful work on [`@hono/zod-validator`](https://github.com/honojs/middleware/tree/main/packages/zod-validator).\n\n## License\n\nMIT\n\n## Contributing\n\nThis project lives primarily at [git.average.name](https://git.average.name/AverageHelper/hono-superstruct-validator). Read-only mirrors also exist on [Codeberg](https://codeberg.org/AverageHelper/hono-superstruct-validator) and [GitHub](https://github.com/AverageHelper/hono-superstruct-validator). Issues or pull requests should be filed at [git.average.name](https://git.average.name/AverageHelper/hono-superstruct-validator). You may sign in or create an account directly, or use one of several OAuth 2.0 providers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faveragehelper%2Fhono-superstruct-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faveragehelper%2Fhono-superstruct-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faveragehelper%2Fhono-superstruct-validator/lists"}