{"id":15579026,"url":"https://github.com/dapper91/aiohttp-validator","last_synced_at":"2025-07-13T19:40:38.803Z","repository":{"id":44703753,"uuid":"453415928","full_name":"dapper91/aiohttp-validator","owner":"dapper91","description":"aiohttp simple pydantic validator","archived":false,"fork":false,"pushed_at":"2023-11-16T18:25:26.000Z","size":31,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-09T13:51:05.771Z","etag":null,"topics":["aiohttp","aiohttp-server","http","pydantic","validation","validator"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dapper91.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,"governance":null}},"created_at":"2022-01-29T14:08:18.000Z","updated_at":"2022-01-30T08:13:34.000Z","dependencies_parsed_at":"2023-11-16T19:58:57.538Z","dependency_job_id":null,"html_url":"https://github.com/dapper91/aiohttp-validator","commit_stats":{"total_commits":22,"total_committers":2,"mean_commits":11.0,"dds":"0.045454545454545414","last_synced_commit":"f7b5be32e3f8fad416869c0fff1cdc615e113ac0"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/dapper91/aiohttp-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapper91%2Faiohttp-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapper91%2Faiohttp-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapper91%2Faiohttp-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapper91%2Faiohttp-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dapper91","download_url":"https://codeload.github.com/dapper91/aiohttp-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapper91%2Faiohttp-validator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265197505,"owners_count":23726426,"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":["aiohttp","aiohttp-server","http","pydantic","validation","validator"],"created_at":"2024-10-02T19:13:37.569Z","updated_at":"2025-07-13T19:40:38.757Z","avatar_url":"https://github.com/dapper91.png","language":"Python","readme":"# aiohttp-validator\n\n[![Downloads][download-badge]][download-url]\n[![License][licence-badge]][licence-url]\n[![Python Versions][python-version-badge]][python-version-url]\n[![Build status][build-badge]][build-url]\n[![Code coverage][coverage-badge]][coverage-url]\n\n[download-badge]: https://static.pepy.tech/personalized-badge/aiohttp-validator?period=month\u0026units=international_system\u0026left_color=grey\u0026right_color=orange\u0026left_text=Downloads/month\n[download-url]: https://pepy.tech/project/aiohttp-validator\n[licence-badge]: https://img.shields.io/badge/license-Unlicense-blue.svg\n[licence-url]: https://github.com/dapper91/aiohttp-validator/blob/master/LICENSE\n[python-version-badge]: https://img.shields.io/pypi/pyversions/aiohttp-validator.svg\n[python-version-url]: https://pypi.org/project/aiohttp-validator\n\n[build-badge]: https://github.com/dapper91/aiohttp-validator/actions/workflows/test.yml/badge.svg?branch=master\n[build-url]: https://github.com/dapper91/aiohttp-validator/actions/workflows/test.yml\n[coverage-badge]: https://codecov.io/gh/dapper91/aiohttp-validator/branch/master/graph/badge.svg\n[coverage-url]: https://codecov.io/gh/dapper91/aiohttp-validator\n\naiohttp simple pydantic http request validator\n\n\n## Installation\n\n```shell\npip install aiohttp-validator\n```\n\n\n## A Simple Example\n\n```py\nimport datetime as dt\nfrom typing import Any, Dict, List, TypedDict\nfrom uuid import UUID\n\nimport pydantic\nfrom aiohttp import web\n\nimport aiohttp_validator as validator\n\nroutes = web.RouteTableDef()\n\n\n@routes.get('/posts')\n@validator.validated()\nasync def get_posts(request: web.Request, tags: List[str], limit: pydantic.conint(gt=0, le=100), offset: int = 0):\n    assert isinstance(tags, list)\n    assert isinstance(limit, int)\n    assert isinstance(offset, int)\n    # your code here ...\n\n    return web.Response(status=200)\n\n\nclass RequestHeaders(TypedDict):\n    requestId: int\n\n\nclass User(pydantic.BaseModel):\n    name: str\n    surname: str\n\n\nclass Post(pydantic.BaseModel):\n    title: str\n    text: str\n    timestamp: float\n    author: User\n    tags: List[str] = pydantic.Field(default_factory=list)\n\n\n@routes.post('/posts/{section}/{date}')\n@validator.validated(config=pydantic.ConfigDict(extra='forbid'))\nasync def create_post(request: web.Request, body: Post, headers: RequestHeaders, section: str, date: dt.date):\n    assert isinstance(body, Post)\n    assert isinstance(headers, dict)\n    assert isinstance(date, dt.date)\n    assert isinstance(section, str)\n    # your code here ...\n\n    return web.Response(status=201)\n\n\nclass AuthCookies(pydantic.BaseModel):\n    tokenId: UUID\n\n\n@routes.post('/users')\n@validator.validated(config=pydantic.ConfigDict(extra='forbid'))\nasync def create_user(request: web.Request, body: Dict[str, Any], headers: RequestHeaders, cookies: AuthCookies):\n    assert isinstance(body, dict)\n    assert isinstance(headers, RequestHeaders)\n    assert isinstance(cookies, AuthCookies)\n    # your code here ...\n\n    return web.Response(status=201)\n\napp = web.Application()\napp.add_routes(routes)\n\nweb.run_app(app, port=8080)\n\n```\n\nIf any path or query parameter name are clashes with body, headers or cookies argument\nfor some reason the last can be renamed:\n\n```py\n@routes.post('/{cookies}')\n@validator.validated(cookies_argname='_cookies')\nasync def method(request: web.Request, body: Dict[str, Any], _cookies: AuthCookies, cookies: str):\n    # your code here ...\n\n    return web.Response(status=201)\n```\n\nIf any argname is `None` the corresponding request part will not be passed to the function\nand argname can be used as a path or query parameter.\n\n```py\n@routes.post('/{body}/{headers}')\n@validator.validated(body_argname=None, headers_argname=None, cookies_argname=None)\nasync def method(request: web.Request, body: str, headers: str, cookies: str = ''):\n    # your code here ...\n\n    return web.Response(status=201)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdapper91%2Faiohttp-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdapper91%2Faiohttp-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdapper91%2Faiohttp-validator/lists"}