{"id":17244098,"url":"https://github.com/mcintyre321/valueof","last_synced_at":"2025-10-06T00:36:26.161Z","repository":{"id":39614729,"uuid":"99736521","full_name":"mcintyre321/ValueOf","owner":"mcintyre321","description":"Deal with Primitive Obsession - define ValueObjects in a single line (of C#).","archived":false,"fork":false,"pushed_at":"2023-03-27T18:23:17.000Z","size":21,"stargazers_count":933,"open_issues_count":20,"forks_count":41,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-09-05T05:57:21.027Z","etag":null,"topics":["ddd","domain-model","valueobject"],"latest_commit_sha":null,"homepage":"","language":"C#","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/mcintyre321.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-08-08T21:11:25.000Z","updated_at":"2025-09-01T17:38:12.000Z","dependencies_parsed_at":"2024-01-15T13:35:48.025Z","dependency_job_id":null,"html_url":"https://github.com/mcintyre321/ValueOf","commit_stats":{"total_commits":13,"total_committers":8,"mean_commits":1.625,"dds":0.6923076923076923,"last_synced_commit":"84e9e841374007da1ba1319e2cb4d00b4313d959"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mcintyre321/ValueOf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcintyre321%2FValueOf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcintyre321%2FValueOf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcintyre321%2FValueOf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcintyre321%2FValueOf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcintyre321","download_url":"https://codeload.github.com/mcintyre321/ValueOf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcintyre321%2FValueOf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278542660,"owners_count":26004060,"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-10-05T02:00:06.059Z","response_time":54,"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":["ddd","domain-model","valueobject"],"created_at":"2024-10-15T06:17:45.902Z","updated_at":"2025-10-06T00:36:26.144Z","avatar_url":"https://github.com/mcintyre321.png","language":"C#","readme":"# ValueOf\n\n\u003e install-package ValueOf\n\n## What is this library\n\n\u003e The Smell: Primitive Obsession is using primitive data types to represent domain ideas. For example, we use a String to represent a message, an Integer to represent an amount of money, or a Struct/Dictionary/Hash to represent a specific object.\n\u003e The Fix: Typically, we introduce a ValueObject in place of the primitive data, then watch like magic as code from all over the system shows FeatureEnvySmell and wants to be on the new ValueObject. We move those methods, and everything becomes right with the world.\n\u003e - http://wiki.c2.com/?PrimitiveObsession\n\nValueOf lets you define ValueObject Types in a single line of code. Use them everywhere to strengthen your codebase.\n\n```\npublic class EmailAddress : ValueOf\u003cstring, EmailAddress\u003e { }\n\n...\n\nEmailAddress emailAddress = EmailAddress.From(\"foo@bar.com\");\n\n```\n\nThe ValueOf class implements `.Equals` and `.GetHashCode()` for you.\n\nYou can use C# 7 Tuples for more complex Types with multiple values:\n\n```\n    public class Address : ValueOf\u003c(string firstLine, string secondLine, Postcode postcode), Address\u003e { }\n\n```\n\n### Validation\n\nYou can add validation to your Types by overriding the `protected void Validate() { } ` method:\n\n```\npublic class ValidatedClientRef : ValueOf\u003cstring, ValidatedClientRef\u003e\n{\n    protected override void Validate()\n    {\n        if (string.IsNullOrWhiteSpace(Value))\n            throw new ArgumentException(\"Value cannot be null or empty\");\n    }\n}\t\n\n```\n\n## See Also\n\nIf you liked this, you'll probably like another project of mine [OneOf](https://github.com/mcintyre321/OneOf) which provides Discriminated Unions for C#, allowing stronger compile time guarantees when writing branching logic.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcintyre321%2Fvalueof","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcintyre321%2Fvalueof","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcintyre321%2Fvalueof/lists"}