{"id":17081479,"url":"https://github.com/benfoster/o9d-guard","last_synced_at":"2025-04-12T21:01:50.248Z","repository":{"id":47033098,"uuid":"338518034","full_name":"benfoster/o9d-guard","owner":"benfoster","description":"Opinionated Guard Extensions for .NET","archived":false,"fork":false,"pushed_at":"2021-09-16T13:12:09.000Z","size":526,"stargazers_count":13,"open_issues_count":18,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-10T10:13:46.858Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://benfoster.github.io/o9d-guard/","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/benfoster.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":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2021-02-13T07:09:08.000Z","updated_at":"2023-12-06T08:28:47.000Z","dependencies_parsed_at":"2022-09-02T22:51:29.177Z","dependency_job_id":null,"html_url":"https://github.com/benfoster/o9d-guard","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benfoster%2Fo9d-guard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benfoster%2Fo9d-guard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benfoster%2Fo9d-guard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benfoster%2Fo9d-guard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benfoster","download_url":"https://codeload.github.com/benfoster/o9d-guard/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631685,"owners_count":21136561,"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-10-14T12:53:07.517Z","updated_at":"2025-04-12T21:01:50.212Z","avatar_url":"https://github.com/benfoster.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg alt=\"Guard Icon\" src=\"src/Guard/assets/icon.png\" width=\"64px\" /\u003e\n\n# Guard\n\n[![NuGet](https://img.shields.io/nuget/v/O9d.Guard.svg)](https://www.nuget.org/packages/O9d.Guard) \n[![NuGet](https://img.shields.io/nuget/dt/O9d.Guard.svg)](https://www.nuget.org/packages/O9d.Guard)\n[![License](https://img.shields.io/:license-mit-blue.svg)](https://benfoster.mit-license.org/)\n\n![Build](https://github.com/benfoster/o9d-guard/workflows/Build/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/benfoster/o9d-guard/badge.svg?branch=main)](https://coveralls.io/github/benfoster/o9d-guard?branch=main)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=benfoster_o9d-guard\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=benfoster_o9d-guard)\n[![GuardRails badge](https://api.guardrails.io/v2/badges/benfoster/o9d-guard.svg?token=461e73c50b8d8bfaf110ed2086379a8308a4fb8dd342334e79dcadd2dccf0f83\u0026provider=github)](https://dashboard.guardrails.io/gh/benfoster/65586)\n[![CodeScene Code Health](https://codescene.io/projects/12974/status-badges/code-health)](https://codescene.io/projects/12974)\n\nGuard is an o[pinionate]d guard/assertions library for .NET that simplifies argument checking. \n\n**Without Guard:**\n\n```c#\npublic Customer(string name, PhoneNumber phone)\n{\n    if (string.IsNullOrWhiteSpace(name))\n    {\n        throw new ArgumentException(\"Name must be provided required\", nameof(name));\n    }\n\n    Name = name;\n    Phone = phone ?? throw new ArgumentNullException(nameof(phone));\n}   \n```\n\n**With Guard:**\n\n```c#\npublic Customer(string name, PhoneNumber phone)\n{\n    Name = name.NotNullOrWhiteSpace(nameof(name));\n    Phone = phone.NotNull(nameof(phone));\n}\n```\n\n## Quick Start\n\nAdd the O9d.Guard package from [NuGet](https://www.nuget.org/packages/O9d.Guard)\n\n```\ndotnet add package O9d.Guard\n```\n\nIf you want to use a pre-release package, you can download them GitHub packages.\n\nImport the `O9d.Guard` namespace and start using the extension to validate arguments.\n\n### Pre-release Packages\n\nPre-release packages can be downloaded from [GitHub Packages](https://github.com/benfoster?tab=packages\u0026repo_name=o9d-guard).\n\n```\ndotnet add package O9d.Guard --prerelease --source https://nuget.pkg.github.com/benfoster/index.json\n```\n\n[More information](https://docs.github.com/en/packages/guides/configuring-dotnet-cli-for-use-with-github-packages) on using GitHub packages with .NET.\n\n## Building locally \n\nThis project uses [Cake](https://cakebuild.net/) to build, test and publish packages. \n\nRun `build.sh` (Mac/Linux) or `build.ps1` (Windows) To build and test the project. \n\nThis will output NuGet packages and coverage reports in the `artifacts` directory.\n\n## Contributing\n\nTo contribute to O9d.Guard, fork the repository and raise a PR. If your change is substantial please [open an issue](https://github.com/benfoster/o9d-guard/issues) first to discuss your objective.\n\n## Docs\n\nThe Guard documentation is built using [DocFx](https://dotnet.github.io/docfx/). To build and serve the docs locally run:\n\n```\n./build.sh --target ServeDocs\n```\n\nThis will serve the docs on http://localhost:8080.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenfoster%2Fo9d-guard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenfoster%2Fo9d-guard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenfoster%2Fo9d-guard/lists"}