{"id":21900536,"url":"https://github.com/keenlycode/dictify","last_synced_at":"2026-04-05T05:02:06.480Z","repository":{"id":57418144,"uuid":"145208338","full_name":"keenlycode/dictify","owner":"keenlycode","description":"Dictify : Documents schema and data validation","archived":false,"fork":false,"pushed_at":"2023-08-21T18:04:46.000Z","size":7922,"stargazers_count":9,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T19:53:58.969Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://keenlycode.github.io/dictify/","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/keenlycode.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":"2018-08-18T09:47:13.000Z","updated_at":"2023-11-26T10:51:49.000Z","dependencies_parsed_at":"2023-11-07T18:29:31.115Z","dependency_job_id":"71b15984-2cf1-4464-9fcd-e3fffb43f1fa","html_url":"https://github.com/keenlycode/dictify","commit_stats":null,"previous_names":["keenlycode/dictify","nitipit/dictify"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keenlycode%2Fdictify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keenlycode%2Fdictify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keenlycode%2Fdictify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keenlycode%2Fdictify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keenlycode","download_url":"https://codeload.github.com/keenlycode/dictify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249145296,"owners_count":21219966,"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-11-28T15:08:40.741Z","updated_at":"2026-04-05T05:02:01.449Z","avatar_url":"https://github.com/keenlycode.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 style=\"width: 100%; text-align: center; margin-bottom: 0.5rem;\"\u003e{ Dictify }\u003c/h1\u003e\n\n\u003ch2 style=\"width: 100%; text-align: center; margin-top: 0.5rem;\"\u003eDocuments schema and data validation\u003c/h2\u003e\n\n\u003cdiv style=\"display: flex; justify-content: center;\"\u003e\n    \u003ca class=\"button\"\n            href=\"https://github.com/nitipit/dictify\"\u003e\n        \u003cel-icon set=\"brand\" name=\"github\" style=\"margin-right: 0.2rem;\"\u003e\u003c/el-icon\u003e\n        Github\n    \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cpkt-tag\u003e{ dictify }\u003c/pkt-tag\u003e is a python library to define data schema and validation with simple and flexible syntax for documents data type such as **JSON** and **Python** `dict` object.\n\n\u003cdiv id=\"new-features\"\u003e\n    \u003cpkt-badge style=\"padding:0.1rem 0.5rem;\"\u003e! New in V3.1.0\u003c/pkt-badge\u003e\n    \u003ca href=\"guide/usage.html#strict-mode\" class=\"pkt-box-arrow-left\"\u003estrict mode\u003c/a\u003e\n    \u003ca href=\"guide/usage.html#post-validation\" class=\"pkt-box-arrow-left\"\u003epost validation\u003c/a\u003e\n\u003c/div\u003e\n\n## Get it\n---\n\n```shell\n$ pip install dictify\n```\n\n## Schema definition\n---\nLet's start with an example note data:\n\n```json\n{\n    \"title\": \"Dictify\",\n    \"content\": \"dictify is easy\",\n    \"timestamp\": \"2021-06-13T05:13:45.326869\"\n}\n```\n\nThe schema condition should be like:\n\n**title**\n1. Required field\n2. Must be `str` instance\n3. Length is \u003c= 300\n\n**content**\n1. Must be `str` instance\n\n**timestamp**\n1. Required field\n2. Default to datetime on creation in ISO format string\n3. Must be a valid ISO datetime string\n\n\n```python\nfrom datetime import datetime\nfrom dictify import Model, Field\n\nclass Note(Model):\n    title = Field(required=True)\\\n        .instance(str)\\\n        .verify(lambda value: len(value) \u003c= 300) # [1]\n\n    content = Field().instance(str)\n\n    timestamp = Field(\n            required=True,\n            default=lambda: datetime.utcnow().isoformat())\\\n        .verify(lambda value: datetime.fromisoformat(value))\n```\n\n\u003e [1] Field validations can be chained.\n\n## Data assignment and validation\n---\n\nAfter schema definition, now we can use it to create `Model` instance with required data.\n\n```python\nnote = Note({'title': 'Dictify', 'content': 'dictify is easy'})\n\n# `note` can be used like a dict object.\n\nnote.update({\n    \"content\": \"Updated content\",\n})\nnote[\"content\"] = \"Updated again\"\n\n# Code below will raise `Model.Error`.\nnote.update({'title': 0})\nnote['title'] = 0\n```\n\n\u003e Note : Use `try..except` to catch errors if needed.\n\n## Convert data to native 'dict' or 'JSON'\n---\n\n```python\nimport json\n\nnote_dict = dict(note) # Convert to python built-in `dict`\nnote_json = json.dumps(note)  # Convert to JSON string\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeenlycode%2Fdictify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeenlycode%2Fdictify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeenlycode%2Fdictify/lists"}