{"id":22428238,"url":"https://github.com/technicallyjosh/koa-fluent-validation","last_synced_at":"2025-03-27T06:43:26.615Z","repository":{"id":22795513,"uuid":"97337760","full_name":"technicallyjosh/koa-fluent-validation","owner":"technicallyjosh","description":"Fluent, functional, and extendable validation for Koa 2. Built with validator behind the scenes.","archived":false,"fork":false,"pushed_at":"2023-01-03T21:04:56.000Z","size":1246,"stargazers_count":0,"open_issues_count":14,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-15T08:05:05.848Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/technicallyjosh.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":"2017-07-15T19:28:14.000Z","updated_at":"2019-11-27T05:35:57.000Z","dependencies_parsed_at":"2023-01-13T22:14:09.700Z","dependency_job_id":null,"html_url":"https://github.com/technicallyjosh/koa-fluent-validation","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicallyjosh%2Fkoa-fluent-validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicallyjosh%2Fkoa-fluent-validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicallyjosh%2Fkoa-fluent-validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicallyjosh%2Fkoa-fluent-validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/technicallyjosh","download_url":"https://codeload.github.com/technicallyjosh/koa-fluent-validation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245798538,"owners_count":20673901,"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":"2024-12-05T20:14:12.269Z","updated_at":"2025-03-27T06:43:26.586Z","avatar_url":"https://github.com/technicallyjosh.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# koa-fluent-validation\n\n[![npm](https://img.shields.io/npm/v/koa-fluent-validation.svg?style=for-the-badge)](https://npmjs.com/package/koa-fluent-validation)\n[![Travis (.org)](https://img.shields.io/travis/technicallyjosh/koa-fluent-validation.svg?style=for-the-badge)](https://travis-ci.org/technicallyjosh/koa-fluent-validation)\n[![David](https://img.shields.io/david/technicallyjosh/koa-fluent-validation.svg?style=for-the-badge)](https://david-dm.org/technicallyjosh/koa-fluent-validation)\n\nFluent, functional, and extendable validation for Koa 2 body, params, and query. Built on [validator](https://github.com/chriso/validator.js/) for base validations and filters.\n\n## Installation\n\n```console\n$ npm i koa-fluent-validation\n```\n\n## Requirements\n\n- NodeJS \u003e= 7.6\n- **For validating parameters, [koa-router](https://github.com/alexmingoia/koa-router)'s implementation is used with `ctx.params`.**\n\n## Usage\n\n### Simple App Example\n\n```js\nconst Koa = require('koa');\nconst bodyparser = require('koa-bodyparser');\nconst { validation, v, f } = require('koa-fluent-validation');\n\nconst app = new Koa();\n\napp.use(bodyparser());\napp.use(validation());\n\napp.use(async (ctx, next) =\u003e {\n  try {\n    await next();\n  } catch (e) {\n    if (e.status === 422) {\n      ctx.body = ctx.validationErrors;\n      return;\n    }\n\n    // ... some other handling here etc\n  }\n});\n\n// simple post route\napp.use(async (ctx, next) =\u003e {\n  if (ctx.method !== 'POST') {\n    ctx.throw(404);\n    return;\n  }\n\n  ctx.validateBody(\n    {\n      firstName: v()\n        .required()\n        .string(),\n      lastName: v()\n        .required()\n        .string(),\n    },\n    {\n      firstName: f().trim(),\n      lastName: f().trim(),\n    },\n  );\n\n  // your code here\n});\n\napp.listen(8080);\n```\n\n## Documentation\n\n**For documentation see the [wiki](https://github.com/technicallyjosh/koa-fluent-validation/wiki)!**\n\n## TODO\n\n- [] Filter Tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnicallyjosh%2Fkoa-fluent-validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechnicallyjosh%2Fkoa-fluent-validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnicallyjosh%2Fkoa-fluent-validation/lists"}