{"id":13579704,"url":"https://github.com/keithasaurus/koda-validate","last_synced_at":"2026-01-07T02:13:11.338Z","repository":{"id":41353758,"uuid":"455992790","full_name":"keithasaurus/koda-validate","owner":"keithasaurus","description":"Typesafe, Composable Validation","archived":false,"fork":false,"pushed_at":"2024-11-18T06:12:22.000Z","size":1646,"stargazers_count":113,"open_issues_count":1,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-11-18T06:44:30.361Z","etag":null,"topics":["python","python310","python311","python312","python38","python39","typesafe","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keithasaurus.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":"2022-02-05T21:44:15.000Z","updated_at":"2024-11-07T01:05:01.000Z","dependencies_parsed_at":"2023-02-15T18:15:43.909Z","dependency_job_id":"d17f306c-a315-4591-a735-def6a28db00f","html_url":"https://github.com/keithasaurus/koda-validate","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keithasaurus%2Fkoda-validate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keithasaurus%2Fkoda-validate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keithasaurus%2Fkoda-validate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keithasaurus%2Fkoda-validate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keithasaurus","download_url":"https://codeload.github.com/keithasaurus/koda-validate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415793,"owners_count":20935383,"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":["python","python310","python311","python312","python38","python39","typesafe","validation","validator"],"created_at":"2024-08-01T15:01:42.113Z","updated_at":"2026-01-07T02:13:11.333Z","avatar_url":"https://github.com/keithasaurus.png","language":"Python","readme":"# Koda Validate\n\nKoda Validate is a library and toolkit for building composable and typesafe validators. In many cases,\nvalidators can be derived from typehints (e.g. TypedDicts, dataclasses, and NamedTuples). For everything else, you can \ncombine existing validation logic, or write your own. At its heart, Koda Validate is just a few kinds of\ncallables that fit together, so the possibilities are endless. It is async-friendly and comparable in performance to Pydantic 2.\n\nKoda Validate can be used in normal control flow or as a runtime type checker.\n\nDocs: [https://koda-validate.readthedocs.io/en/stable/](https://koda-validate.readthedocs.io/en/stable/)\n\n## At a Glance\n\n```python\nfrom koda_validate import StringValidator\n\nmy_string_validator = StringValidator()\n\nmy_string_validator(\"a string!\")\n#\u003e Valid(\"a string!\")\n\nmy_string_validator(5)\n#\u003e Invalid(...)\n```\n\n#### Additional Validation\n```python\nfrom koda_validate import MaxLength, MinLength\n\nstr_len_validator = StringValidator(MinLength(1), MaxLength(20))\n\nstr_len_validator(\"abc\")\n#\u003e Valid(\"abc\")\n\nstr_len_validator(\"\")\n#\u003e Invalid(...)\n\nstr_len_validator(\"abcdefghijklmnopqrstuvwxyz\")\n#\u003e Invalid(...)\n```\n\n#### Combining Validators\n\n```python\nfrom koda_validate import ListValidator, StringValidator\n\nlist_string_validator = ListValidator(StringValidator())\n\nlist_string_validator([\"a\", \"b\", \"c\"])\n# \u003e Valid([\"a\", \"b\", \"c\"])\n\nlist_string_validator([1, 2, 3])\n# \u003e Invalid(...)\n```\n\n#### Derived Validators\n\n```python\nfrom typing import TypedDict\nfrom koda_validate import (TypedDictValidator, Valid, Invalid)\nfrom koda_validate.serialization import to_serializable_errs\n\nclass Person(TypedDict):\n    name: str\n    hobbies: list[str]\n\n\nperson_validator = TypedDictValidator(Person)\n\nmatch person_validator({\"name\": \"Guido\"}):\n    case Valid(string_list):\n        print(f\"woohoo, valid!\")\n    case Invalid() as invalid:\n        # readable errors\n        print(to_serializable_errs(invalid))\n\n#\u003e {'hobbies': ['key missing']}\n```\n\n#### Runtime Type Checking\n\n```python\nfrom koda_validate.signature import validate_signature\n\n@validate_signature\ndef add(a: int, b: int) -\u003e int:\n    return a + b\n\n\nadd(1, 2)  # returns 3\n\nadd(1, \"2\")  # raises `InvalidArgsError`\n# koda_validate.signature.InvalidArgsError:\n# Invalid Argument Values\n# -----------------------\n# b='2'\n#     expected \u003cclass 'int'\u003e\n```\n\nThere's much, much more in the [Docs](https://koda-validate.readthedocs.io/en/stable/).\n\n\n## Something's Missing or Wrong \nOpen an [issue on GitHub](https://github.com/keithasaurus/koda-validate/issues) please!\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeithasaurus%2Fkoda-validate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeithasaurus%2Fkoda-validate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeithasaurus%2Fkoda-validate/lists"}