{"id":37034450,"url":"https://github.com/fluentcontracts/fluentcontracts","last_synced_at":"2026-01-14T04:02:15.390Z","repository":{"id":235574880,"uuid":"136153351","full_name":"FluentContracts/FluentContracts","owner":"FluentContracts","description":"Fluent argument validation for fluent software development.","archived":false,"fork":false,"pushed_at":"2025-03-17T00:56:39.000Z","size":417,"stargazers_count":40,"open_issues_count":7,"forks_count":3,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-11-07T16:07:12.539Z","etag":null,"topics":["arguments","contracts","fluent-api","fluent-interface","validation"],"latest_commit_sha":null,"homepage":"https://fluentcontracts.github.io","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/FluentContracts.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":"docs/SupportedContracts.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"totollygeek","buy_me_a_coffee":"totollygeek","patreon":"totollygeek","custom":["https://paypal.me/totollygeek"]}},"created_at":"2018-06-05T09:28:08.000Z","updated_at":"2025-01-05T16:22:59.000Z","dependencies_parsed_at":"2024-05-18T11:25:44.686Z","dependency_job_id":"3245b646-d06b-43e1-84db-e6d99132fee6","html_url":"https://github.com/FluentContracts/FluentContracts","commit_stats":null,"previous_names":["fluentcontracts/fluentcontracts"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/FluentContracts/FluentContracts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluentContracts%2FFluentContracts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluentContracts%2FFluentContracts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluentContracts%2FFluentContracts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluentContracts%2FFluentContracts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FluentContracts","download_url":"https://codeload.github.com/FluentContracts/FluentContracts/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluentContracts%2FFluentContracts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"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":["arguments","contracts","fluent-api","fluent-interface","validation"],"created_at":"2026-01-14T04:02:14.770Z","updated_at":"2026-01-14T04:02:15.382Z","avatar_url":"https://github.com/FluentContracts.png","language":"C#","readme":"\u003cimg alt=\"Logo\" width=\"100px\" src=\"https://github.com/FluentContracts/FluentContracts/raw/develop/assets/icon.png\"/\u003e\n\n# FluentContracts\n[![NuGet Version](https://img.shields.io/nuget/v/FluentContracts?style=for-the-badge\u0026logo=nuget\u0026logoColor=white\u0026color=green)](https://www.nuget.org/packages/FluentContracts/)\n[![NuGet Downloads](https://img.shields.io/nuget/dt/FluentContracts?style=for-the-badge\u0026logo=nuget\u0026logoColor=white)](https://www.nuget.org/packages/FluentContracts/)\n\nAPI for defining argument validation contracts in a fluent manner.\n\nInspired by [FluentAssertions](https://github.com/fluentassertions/fluentassertions)\n\n## Why another validation library\n\nI am  perfectly aware of the other libraries out there, that are doing the same stuff.\n\nLibraries like [FluentValidation](https://github.com/FluentValidation/FluentValidation) and `Guard` from [.NET Community Toolkit](https://github.com/CommunityToolkit/dotnet) are awesome \nand have tons of functionality, support and experience. If you like those and use them already, that is fine.\n\nI did this one, because I don't really like how the other libraries require you to write, in order to achieve the validation.\nIt is pretty verbose for my taste. I wanted to make something more simple and \"human-readable\", the same way [FluentAssertions](https://github.com/fluentassertions/fluentassertions) does it for unit testing.\n\n## Usage\n\nThe usage of the contracts is pretty simple. You can use the extension methods everywhere you want to do a validation of some variable.\n\nGenerally when we write methods, constructors, etc., we do validation like that:\n```csharp\npublic void AddOrder(Order myOrder)\n{\n    if (myOrder == null) throw new ArgumentNullException(nameof(myOrder));    \n    if (myOrder.Quantity \u003c 5) throw new OrderQuantityException(\"Order quantity cannot be less than 5\");\n    \n    ...\n}\n```\n\nWith `FluentContracts` your code will look like this:\n```csharp\npublic void AddOrder(Order myOrder)\n{\n    myOrder\n        .Must()\n        .NotBeNull()\n        .And\n        .Satisfy\u003cOrderQuantityException\u003e(\n            o =\u003e o.Quantity \u003e= 5, \n            \"Order quantity cannot be less than 5\");\n    \n    ...\n}\n```\n\nor as simple as:\n\n```csharp\npublic int Divide(int a, int b)\n{\n    b.Must().NotBe(0);    \n    return a / b;\n}\n```\n### User defined exceptions\n\nYou can also throw your own exception like that:\n```csharp\npublic void AddOrder(Order myOrder)\n{\n    myOrder.Must().NotBeNull\u003cOrderNullException\u003e();\n}\n```\n\nThis will throw an instance of `OrderNullException` if `myOrder` is `null`.\n\n## Supported contracts\n\nYou can find them [HERE](docs/SupportedContracts.md).\n\n## Help needed 🙏\n\nMy goal for this project is to become as exhaustive, safe and stable as possible, so people can use it in production and on big projects.\nSo I need some help. If you are interested in helping out just send a pull request, open an issue, etc.\n\n## Repository 🚧\n\n### Builds\n\n|     Type      | Status                                                                                                                                                                                                                                                                 |\n|:-------------:|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n|   Dev Build   | [![Dev Linux](https://img.shields.io/github/actions/workflow/status/FluentContracts/FluentContracts/dev-linux.yml?branch=dev\u0026style=for-the-badge\u0026logo=linux\u0026logoColor=white)](https://github.com/FluentContracts/FluentContracts/actions)                              |\n|   Dev Build   | [![Dev Windows](https://img.shields.io/github/actions/workflow/status/FluentContracts/FluentContracts/dev-windows.yml?branch=dev\u0026style=for-the-badge\u0026logo=windows10\u0026logoColor=white)](https://github.com/FluentContracts/FluentContracts/actions)                      |\n|   Dev Build   | [![Dev MacOS](https://img.shields.io/github/actions/workflow/status/FluentContracts/FluentContracts/dev-macos.yml?branch=dev\u0026style=for-the-badge\u0026logo=Apple\u0026logoColor=white)](https://github.com/FluentContracts/FluentContracts/actions)                              |\n| Code Coverage | [![Coveralls](https://img.shields.io/coverallsCoverage/github/FluentContracts/FluentContracts?branch=dev\u0026style=for-the-badge\u0026logo=coveralls\u0026logoColor=white)](https://coveralls.io/github/FluentContracts/FluentContracts)                                             |\n|    Release    | [![Release](https://img.shields.io/github/actions/workflow/status/FluentContracts/FluentContracts/master-release.yml?branch=master\u0026style=for-the-badge\u0026logo=nuget\u0026logoColor=white\u0026label=NuGet%20Packages)](https://github.com/FluentContracts/FluentContracts/actions) |\n\n### Status\n\n![Alt](https://repobeats.axiom.co/api/embed/5aeeab6e5ce07439108408d66453df63f9379eeb.svg \"Repobeats analytics image\")\n\n### How to build locally\n\n- Clone repos\n- Run `build.cmd`\n\n## Where to find me 🕵️\n\n[![Blog](https://img.shields.io/badge/Blog-todorov.bg-black.svg?style=for-the-badge\u0026logo=jekyll\u0026logoColor=white)](https://todorov.bg)\n[![X](https://img.shields.io/badge/twitter-%40totollygeek-lightgreen.svg?style=for-the-badge\u0026logo=x\u0026logoColor=white)](https://twitter.com/totollygeek)\n[![LinkedIn](https://img.shields.io/badge/linkedin-totollygeek-blue.svg?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white)](https://www.linkedin.com/in/totollygeek)\n[![Mastodon](https://img.shields.io/badge/Mastodon-%40totollygeek@infosec.exchange-darkblue.svg?style=for-the-badge\u0026logo=mastodon\u0026logoColor=white)](https://infosec.exchange/@totollygeek)\n[![Threads](https://img.shields.io/badge/Threads-%40totollygeek-red.svg?style=for-the-badge\u0026logo=threads\u0026logoColor=white)](https://www.threads.net/@totollygeek)\n[![BlueSky](https://img.shields.io/badge/BlueSky-totollygeek.com-lightblue.svg?style=for-the-badge\u0026logo=bluesky\u0026logoColor=white)](https://bsky.app/profile/totollygeek.com)\n[![Linktree](https://img.shields.io/badge/Linktree-totollygeek-yellow.svg?style=for-the-badge\u0026logo=linktree\u0026logoColor=white)](https://linktr.ee/totollygeek)\n[![Email](https://img.shields.io/badge/Email-fluentcontracts@pm.me-blue.svg?style=for-the-badge\u0026logo=proton\u0026logoColor=white)](mailto://fluentcontracts@pm.me)\n\n## Special thanks 🙇‍♂️\n\n#### [Matthias Koch](https://twitter.com/matkoch87)\n\u003e The creator of [NUKE](https://nuke.build), because I cannot build any .NET project without it and because he helped me tremendously in setting up the repository and everything around this project. (_I have also copy-pasted, like his entire build and some markdown files_ 🤫)\n\n#### [Dennis Doomen](https://twitter.com/ddoomen)\n\u003e The \"[FluentAssertions](https://fluentassertions.com/)\" guy. This whole project was inspired by how that library works and I might have copy-pasted also parts of his repo too 😏\n\n## Technology Sponsors 💻\n\u003cimg alt=\"JetBrains Logo\" width=\"300px\" src=\"https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.png\"/\u003e\n\n\u003e Special thanks to [JetBrains](https://www.jetbrains.com/) for supplying a free license for [Rider](https://www.jetbrains.com/rider/), which is my primary IDE of choice for this project!\n\nIcon made by [IconMonk](https://www.flaticon.com/authors/icon-monk) from [Flaticon](https://www.flaticon.com) \n","funding_links":["https://github.com/sponsors/totollygeek","https://buymeacoffee.com/totollygeek","https://patreon.com/totollygeek","https://paypal.me/totollygeek"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluentcontracts%2Ffluentcontracts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluentcontracts%2Ffluentcontracts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluentcontracts%2Ffluentcontracts/lists"}