{"id":38365611,"url":"https://github.com/natanfeitosa/kohi","last_synced_at":"2026-01-17T03:23:29.784Z","repository":{"id":65222816,"uuid":"588022927","full_name":"natanfeitosa/kohi","owner":"natanfeitosa","description":"A powerfull schema validator","archived":false,"fork":false,"pushed_at":"2024-08-23T06:02:36.000Z","size":63,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-25T08:38:33.294Z","etag":null,"topics":["data-science","python3","schema-validation","validation"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/kohi/","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/natanfeitosa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"2023-01-12T06:16:12.000Z","updated_at":"2024-08-23T06:02:40.000Z","dependencies_parsed_at":"2023-10-11T11:37:00.749Z","dependency_job_id":null,"html_url":"https://github.com/natanfeitosa/kohi","commit_stats":{"total_commits":64,"total_committers":2,"mean_commits":32.0,"dds":0.03125,"last_synced_commit":"b9aaf81754eb99cba05fec67f6ae249ee82c50d6"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/natanfeitosa/kohi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natanfeitosa%2Fkohi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natanfeitosa%2Fkohi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natanfeitosa%2Fkohi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natanfeitosa%2Fkohi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/natanfeitosa","download_url":"https://codeload.github.com/natanfeitosa/kohi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natanfeitosa%2Fkohi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28492786,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T02:39:23.645Z","status":"ssl_error","status_checked_at":"2026-01-17T02:34:19.649Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["data-science","python3","schema-validation","validation"],"created_at":"2026-01-17T03:23:29.086Z","updated_at":"2026-01-17T03:23:29.769Z","avatar_url":"https://github.com/natanfeitosa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kohi\n\n\u003cp align=\"center\"\u003eA powerfull schema validator\u003c/p\u003e\n\n![GitHub Repo stars](https://img.shields.io/github/stars/natanfeitosa/kohi)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/natanfeitosa/kohi/pytest.yml?label=Pytest\u0026logo=github)\n![GitHub](https://img.shields.io/github/license/natanfeitosa/kohi)\n![PyPI - Format](https://img.shields.io/pypi/format/kohi)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/kohi)\n![PyPI - Package Version](https://img.shields.io/pypi/v/kohi)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/kohi)\n[![Open Source Helpers](https://www.codetriage.com/natanfeitosa/kohi/badges/users.svg)](https://www.codetriage.com/natanfeitosa/kohi)\n\n## Instalation\n\nVia Poetry:\n```sh\npoetry add kohi\n```\n\nVia PIP:\n```sh\npip install kohi\n```\n\nVia GitHub (recommended only in dev env):\n```sh\ngit clone https://github.com/natanfeitosa/kohi.git \u0026\u0026 cd kohi \u0026\u0026 pip install .\n```\n\n## Quickstart\n\nTo validate a type you can import your schema validator from `kohi` or `from kohi.\u003ctype\u003e import \u003ctype\u003eSchema`\n\ne.g.\n\nLet's check if a person's date of birth is a positive integer less than the current date — 2023 — and greater than or equal to 2005\n\n```python\nfrom kohi import NumberSchema\n# from kohi.number import NumberSchema\n\nn = NumberSchema().int().positive().lt(2023).gte(2005)\n\nprint(n.validate(2005)) # True\nprint(n.validate(2022)) # True\nprint(n.validate(2004)) # False\nprint(n.validate(2023)) # False\n\n# You can see the errors generated in the last `validate` call just by accessing the `errors` property\n# print(n.errors) # ['number must be less than 2022']\n```\n\n## Validators\n\n* [`kohi.base.BaseSchema`](#baseschema)\n\u003e Only one base class for all schema validators\n* [`kohi.number.NumberSchema`](#numberschema)\n\u003e or `kohi.NumberSchema`\n* [`kohi.string.StringSchema`](#stringschema)\n\u003e or `kohi.StringSchema`\n* [`kohi.enum.EnumSchema`](#enumschema)\n\u003e or `kohi.EnumSchema`\n* [`kohi.dictionary.DictSchema`](#dictschema)\n\u003e or `kohi.DictSchema`\n\n## Methods\n\n### `BaseSchema`\n* `add_validator(name, func): Self`\n  \u003e Add a custom data validator\n* `validate(data): bool`\n  \u003e The method to be called when we validate the schema\n* `reset(): None`\n  \u003e Reset error list\n* `throw(): Self`\n  \u003e By default no errors are thrown, but when this method is chained a `ValidationError` will be thrown\n* `add_mutation(): Self`\n  \u003e Add a mutation function than will run after the `validate` method. P.S. Will only be executed in the `parse` method\n* `parse(data): typeof data`\n  \u003e Run the `validate` method, the mutations and return a deep clone of data\n* `default(data): Self`\n  \u003e Set a default value for when the validator receives None and you don't want to generate an error\n* `optional(): Self`\n  \u003e Allow values None\n* `required(error_message=None): Self`\n  \u003e Mark the schema as required. Does not allow values None\n\n### `NumberSchema`\ninherits from [`BaseSchema`](#baseschema)\n\u003e By default validates int and float \n\n* `float(): Self`\n  \u003e Validate only `float`\n* `int(): Self`\n  \u003e Validate only `int`\n* `lt(num): Self`\n  \u003e Validates if the data is less than `num`\n* `gt(num): Self`\n  \u003e Validates if the data is greater than `num`\n* `lte(num): Self`\n  \u003e Validates if the data is less than or equal to `num`\n* `gte(num): Self`\n  \u003e Validates if the data is greater than or equal to `num`\n* `min(num): Self`\n  \u003e Just an alias for `gte(num)`\n* `max(num): Self`\n  \u003e Just an alias for `lte(nun)`\n* `positive(): Self`\n  \u003e Just an alias for `gt(0)`\n* `negative(): Self`\n  \u003e Just an alias for `lt(0)`\n* `nonpositive(): Self`\n  \u003e Just an alias for `lte(0)`\n* `nonnegative(): Self`\n  \u003e Just an alias for `gte(0)`\n\n### StringSchema\ninherits from [`BaseSchema`](#baseschema)\n\n* `min(min_length): Self`\n  \u003e Validate if the data len is greater than or equal to min_length\n* `length(length): Self`\n  \u003e Validate if the data len equal to length\n* `max(max_length): Self`\n  \u003e Validate if the data len is less than or equal to max_length\n* `url(): Self`\n  \u003e Validate if the data is an url\n* `uuid(): Self`\n  \u003e Validate if the data is a valid uuid\n* `starts_with(text): Self`\n  \u003e Validate if the data starts with text\n* `ends_with(text): Self`\n  \u003e Validate if the data ends with text\n\n### EnumSchema\ninherits from [`BaseSchema`](#baseschema)\n\n* `one_of(opts): Self`\n  \u003e Validate if the data is in opts\n* `not_one_of(opts): Self`\n  \u003e Validate that data is different from the values in opts\n\n### DictSchema\ninherits from [`BaseSchema`](#baseschema)\n\n* `props(**props): Self`\n  \u003e Defines the structure of the dictionary in the format `[key]: ClassValidator`\n\n## Dev env\n\n* install development dependencies\n* check types using `mypy`\n* run all tests using `pytest`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatanfeitosa%2Fkohi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnatanfeitosa%2Fkohi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatanfeitosa%2Fkohi/lists"}