{"id":20711112,"url":"https://github.com/cypherpoet/clampedpropertywrapper","last_synced_at":"2026-06-04T17:31:11.273Z","repository":{"id":63907273,"uuid":"356018119","full_name":"CypherPoet/ClampedPropertyWrapper","owner":"CypherPoet","description":"A Swift Property Wrapper for automatically clamping Comparable values within a closed range.","archived":false,"fork":false,"pushed_at":"2021-05-14T21:57:40.000Z","size":2482,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-19T04:48:24.180Z","etag":null,"topics":["clamped","clamped-property-wrapper","input-validation","swift","swift-clamp","swift-package-manager","swift-packages","swift-property-wrapper-packages","swift-property-wrappers","swift-world-domination"],"latest_commit_sha":null,"homepage":"https://cypherpoet.github.io/ClampedPropertyWrapper/","language":"Swift","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/CypherPoet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://tippin.me/@cypher_poet"]}},"created_at":"2021-04-08T18:55:00.000Z","updated_at":"2024-11-12T14:27:07.000Z","dependencies_parsed_at":"2022-11-28T22:54:33.130Z","dependency_job_id":null,"html_url":"https://github.com/CypherPoet/ClampedPropertyWrapper","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":"CypherPoet/swift-package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CypherPoet%2FClampedPropertyWrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CypherPoet%2FClampedPropertyWrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CypherPoet%2FClampedPropertyWrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CypherPoet%2FClampedPropertyWrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CypherPoet","download_url":"https://codeload.github.com/CypherPoet/ClampedPropertyWrapper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242981927,"owners_count":20216503,"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":["clamped","clamped-property-wrapper","input-validation","swift","swift-clamp","swift-package-manager","swift-packages","swift-property-wrapper-packages","swift-property-wrappers","swift-world-domination"],"created_at":"2024-11-17T02:14:05.672Z","updated_at":"2025-03-11T06:21:50.861Z","avatar_url":"https://github.com/CypherPoet.png","language":"Swift","funding_links":["https://tippin.me/@cypher_poet"],"categories":[],"sub_categories":[],"readme":"# Clamped: A Swift Property Wrapper\n\n\u003c!-- Header Logo --\u003e\n\n\u003c!-- \u003cdiv align=\"center\"\u003e\n   \u003cimg width=\"600px\" src=\"./Extras/banner-logo.png\" alt=\"Banner Logo\"\u003e\n\u003c/div\u003e --\u003e\n\n\n\u003c!-- Badges --\u003e\n\n\u003cp\u003e\n    \u003cimg src=\"https://img.shields.io/badge/iOS-13.0+-865EFC.svg\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/iPadOS-13.0+-F65EFC.svg\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/macOS-10.15+-179AC8.svg\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/tvOS-13.0+-41465B.svg\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/watchOS-6.0+-1FD67A.svg\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg\" /\u003e\n    \u003cimg src=\"https://github.com/CypherPoet/ClampedPropertyWrapper/workflows/Build%20\u0026%20Test/badge.svg\" /\u003e\n    \u003ca href=\"https://github.com/apple/swift-package-manager\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://twitter.com/cypher_poet\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Contact-@cypher_poet-lightgrey.svg?style=flat\" alt=\"Twitter: @cypher_poet\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\n\u003cp align=\"center\"\u003e\n\n_A [Swift Property Wrapper](https://docs.swift.org/swift-book/LanguageGuide/Properties.html#ID617) for automatically clamping Comparable values to closed or partial ranges._\n\n\u003cp /\u003e\n\n\n## Features\n\n- ✅ Clamp any `Comparable` type to a `ClosedRange` or a \"Half-Open\" range.\n- ✅ Additional support for initializing clamped `FloatingPoint` properties with a `PartialRangeThrough`, `PartialRangeFrom`, or `PartialRangeUpTo` expression.\n- ✅ Initialize clamped `FloatingPoint` or `FixedWidthInteger` properties with _exclusive_ lower and upper bounds.\n\n## Installation\n\n### Xcode Projects\n\nSelect `File` -\u003e `Swift Packages` -\u003e `Add Package Dependency` and enter `https://github.com/CypherPoet/ClampedPropertyWrapper`.\n\n\n### Swift Package Manager Projects\n\nYou can add `ClampedPropertyWrapper` as a package dependency in your `Package.swift` file:\n\n```swift\nlet package = Package(\n    //...\n    dependencies: [\n        .package(url: \"https://github.com/CypherPoet/ClampedPropertyWrapper\", .upToNextMinor(from: \"0.2.0\")),\n    ],\n    //...\n)\n```\n\nFrom there, refer to `ClampedPropertyWrapper` as a \"target dependency\" in any of _your_ package's targets that need it.\n\n```swift\ntargets: [\n    .target(\n        name: \"YourLibrary\",\n        dependencies: [\n          \"ClampedPropertyWrapper\",\n        ],\n        ...\n    ),\n    ...\n]\n```\n\nThen simply `import ClampedPropertyWrapper` wherever you’d like to use it.\n\n\n## Usage\n\n**Basic Example**:\n\n```swift\nimport ClampedPropertyWrapper\n\nstruct Player {\n\n    @Clamped(\n        above: 0.0.nextDown,\n        andBelow: .infinity\n    )\n    var xp: Double = 0.0\n\n\n    @Clamped(to: 1..\u003c100)\n    var level: Int = 1\n\n\n    @Clamped(above: 0.0, andBelow: Double.infinity)\n    var number: Double = 1.0\n\n\n    @Clamped(to: \"A\"...\"Z\")\n    var firstInitial: Character = \"A\"\n\n\n    @Clamped(to: 0.0...)\n    var ammo: Double = 0.1\n\n\n    @Clamped(to: ...100.0)\n    var reputation: Double = .zero\n\n\n    @Clamped(to: ..\u003c20)\n    var weeklyLeaderboardRankChange: Int = .zero\n}\n```\n\n**You can also take things further in [this project's Xcode Playground](./Examples/Playgrounds/)**:\n\n![Playground Example](./Extras/playground-example-1.png)\n\n## Contributing\n\nContributions to `ClampedPropertyWrapper` are most welcome. Check out some of the [issue templates](./.github/ISSUE_TEMPLATE/) for more info.\n\n\n\n## 💻 Developing\n\n### Requirements\n\n- Xcode 12.5+ (Recommended)\n\n\n### 📜 Generating Documentation\n\nDocumentation is generated by [Swift Doc](https://github.com/SwiftDocOrg/swift-doc). Installation instructions can be found [here](https://github.com/SwiftDocOrg/swift-doc#installation), and as soon as you have it set up, docs can be generated simply by running `./Scripts/generate-html-docs.zsh` from the command line.\n\n📝 Note that this will only generate a `.build/documentation` folder for you to view locally. This folder is being ignored by `git`, and a GitHub [action](./.github/workflows/PublishDocumentation.yml) exists to automatically generate docs at the root level and serve them on the project's `gh-pages` branch.\n\n\n## 🏷 License\n\n`ClampedPropertyWrapper` is available under the MIT license. See the [LICENSE file](./LICENSE) for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcypherpoet%2Fclampedpropertywrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcypherpoet%2Fclampedpropertywrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcypherpoet%2Fclampedpropertywrapper/lists"}