{"id":34095287,"url":"https://github.com/oodesigns/constrained-values","last_synced_at":"2026-03-17T22:36:42.533Z","repository":{"id":314917534,"uuid":"1057009309","full_name":"OODesigns/constrained-values","owner":"OODesigns","description":"A Python library for creating type-safe, self-validating value objects using a powerful transformation and validation pipeline.","archived":false,"fork":false,"pushed_at":"2025-10-29T08:18:30.000Z","size":185,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-28T15:46:30.804Z","etag":null,"topics":["constrained-enum","constrained-range","constrained-value","constraint-programming","python","validated-enum","validated-range","validated-value","validation","validation-library","validator","value-object"],"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/OODesigns.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-15T06:47:16.000Z","updated_at":"2025-10-29T08:18:33.000Z","dependencies_parsed_at":"2025-09-15T17:28:00.345Z","dependency_job_id":"7746bce0-1ca6-404e-9d3b-f78a80508575","html_url":"https://github.com/OODesigns/constrained-values","commit_stats":null,"previous_names":["oodesigns/constrained-values"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/OODesigns/constrained-values","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OODesigns%2Fconstrained-values","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OODesigns%2Fconstrained-values/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OODesigns%2Fconstrained-values/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OODesigns%2Fconstrained-values/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OODesigns","download_url":"https://codeload.github.com/OODesigns/constrained-values/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OODesigns%2Fconstrained-values/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28128485,"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","status":"online","status_checked_at":"2025-12-30T02:00:05.476Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["constrained-enum","constrained-range","constrained-value","constraint-programming","python","validated-enum","validated-range","validated-value","validation","validation-library","validator","value-object"],"created_at":"2025-12-14T15:11:06.531Z","updated_at":"2025-12-30T15:05:30.012Z","avatar_url":"https://github.com/OODesigns.png","language":"Python","readme":"[![Docs](https://img.shields.io/badge/docs-latest-brightgreen.svg?logo=readthedocs\u0026logoColor=white)](https://OODesigns.github.io/constrained-values/constrained_values.html)\n[![Build Status](https://github.com/oodesigns/constrained-values/actions/workflows/website.yml/badge.svg)](https://github.com/OODesigns/constrained-values/actions)\n[![PyPI Version](https://img.shields.io/pypi/v/constrained-values.svg?logo=pypi\u0026logoColor=white)](https://pypi.org/project/constrained-values/)\n![Python Versions](https://img.shields.io/pypi/pyversions/constrained-values.svg)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n## Constrained Values\n\nA lightweight Python library for **creating type-safe, self-validating value objects** — transforming primitive data into meaningful, domain-aware objects with rich validation and transformation pipelines.\n\n---\n\n## 🧭 Philosophy: Beyond Primitive Types\n\nIn most codebases, we pass around raw values without context:\n\n- Is `temperature = 25` Celsius or Fahrenheit?\n- Is `spi_mode = 2` valid for this device?\n- What does `-32768` mean again?\n\nPrimitive values lack **meaning**, **constraints**, and **domain intent**.  \nThis is *Primitive Obsession* — a subtle but pervasive design smell.\n\n**Constrained Values** replaces primitives with expressive, validated objects that make **validity explicit**.  \nEach object carries its **status** (`OK` or `EXCEPTION`) and associated errors.  \n\nBy default, invalid values can exist safely and report their state — but if you want to enforce strict invariants, you can enable **exception mode** to raise immediately on invalid input.\n\n📖 [**Full Documentation →**](https://oodesigns.github.io/constrained-values/constrained_values.html#the-philosophy-beyond-primitive-types)\n\n---\n\n## ✨ Features\n\n- 🧩 **Rich Value Objects** – Replace primitives with expressive, validated domain objects.\n- 🔗 **Composable Pipelines** – Chain multiple validation and transformation strategies.\n- 🧠 **Built-in Validators** – Range checks, enums, type coercion, and more.\n- ⚙️ **Custom Logic** – Easily extend with your own domain-specific rules.\n- 🚦 **Clear Error Handling** – Track validation status and descriptive messages.\n- 🧯 **Strict/Exception Mode (optional)** – By default, invalid values are reported non-destructively; enable strict mode to raise exceptions and enforce invariants at creation.\n- 🧾 **Type-Safety** – Each value enforces its canonical type at runtime.\n\n---\n\n## 🚀 Installation\n\n```bash\npip install constrained-values\n```\n## 💡 Quick Example\n\n```python\nfrom constrained_values import RangeValue\n\nclass Temperature(RangeValue):\n    \"\"\"Temperature constrained between 0 and 100°C.\"\"\"\n    def __init__(self, value):\n        super().__init__(value, low_value=0, high_value=100)\n\ndef main() -\u003e None:\n    # ✅ Valid temperature\n    t = Temperature(42)\n    print(\"Value:\", t.value)        # 42\n    print(\"Status:\", t.status.name) # OK\n    print(\"Details:\", t.details)    # validation successful\n\n    # 🚫 Invalid temperature\n    t_invalid = Temperature(120)\n    print(\"Value:\", t_invalid.value)   # None\n    print(\"Status:\", t_invalid.status) # Status.EXCEPTION\n    print(\"Details:\", t_invalid.details)  # Value must be less than or equal to 100, got 120\n\nif __name__ == \"__main__\":\n    main()\n```\n## 🔥 Strict version\nIf you want the behavior where invalid input throws immediately, use the StrictValue mixin:\n```python\nclass StrictTemperature(RangeValue, StrictValue):\n    \"\"\"Same range constraint but raises if invalid.\"\"\"\n    def __init__(self, value):\n        RangeValue.__init__(self, value, low_value=0, high_value=100)\n\ndef main() -\u003e None:\n    t = StrictTemperature(42)\n    print(\"Value:\", t.value) # 42\n\n    try:\n        StrictTemperature(120)\n    except ValueError as e:\n        print(e) # Failed Constraints for value - '120': Value must be less than or equal to 100, got 120\n\nif __name__ == \"__main__\":\n    main()\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foodesigns%2Fconstrained-values","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foodesigns%2Fconstrained-values","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foodesigns%2Fconstrained-values/lists"}