{"id":21602404,"url":"https://github.com/a-patel/litexguard","last_synced_at":"2026-04-02T15:03:08.665Z","repository":{"id":109325618,"uuid":"133342891","full_name":"a-patel/LiteXGuard","owner":"a-patel","description":"This library provides guard clauses that could be used to guard against not expected values. It provides conditions for objects, strings, numerics, datatime and enumerables. It is possible to configure which exception should be thrown.","archived":false,"fork":false,"pushed_at":"2022-05-17T18:36:25.000Z","size":56,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-20T15:12:36.373Z","etag":null,"topics":["arguments","asp-net-core","aspnet-core","aspnetcore","clause","csharp","guard","litex"],"latest_commit_sha":null,"homepage":null,"language":null,"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/a-patel.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}},"created_at":"2018-05-14T10:16:00.000Z","updated_at":"2022-05-17T18:36:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"901f9e53-0c32-4dff-8ad7-9f5da6e6d5d8","html_url":"https://github.com/a-patel/LiteXGuard","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/a-patel/LiteXGuard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-patel%2FLiteXGuard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-patel%2FLiteXGuard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-patel%2FLiteXGuard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-patel%2FLiteXGuard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a-patel","download_url":"https://codeload.github.com/a-patel/LiteXGuard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-patel%2FLiteXGuard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31308589,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","asp-net-core","aspnet-core","aspnetcore","clause","csharp","guard","litex"],"created_at":"2024-11-24T19:13:17.675Z","updated_at":"2026-04-02T15:03:08.625Z","avatar_url":"https://github.com/a-patel.png","language":null,"funding_links":["https://www.buymeacoffee.com/iamaashishpatel"],"categories":[],"sub_categories":[],"readme":"# LiteXGuard\nLiteX.Guard is a simple guard clause argument validation library, that helps you with validation of your arguments. \n\nA simple package with guard clause helper methods. This library provides guard clauses that could be used to guard against not expected values. It provides conditions for objects, strings, numerics, datatime and enumerables. It is possible to configure which exception should be thrown.\n\nArgument validation made simple and unified. It ensures arguments conforms to simple validation rules and provides an uniformed exception throwing strategy if arguments are invalid.\n\nIt's developed for .NET Standard 2.0 and available via NuGet.\n\n\n\n### Install package\n\u003e Install via [Nuget](https://www.nuget.org/packages/LiteX.Guard/).\n\n```Powershell\nPM\u003e Install-Package LiteX.Guard\n```\n\n\n## Supported Guard Clauses\n\nNull/Empty\n- **Guard.NotNull** (throws if input is null)\n- **Guard.NotNullOrEmpty** (throws if string input is null or empty)\n\nRange\n- **Guard.InRange** (throws if specified value is greater than or equal to a minimum value and less than)\n- **Guard.LessThan** (throws if specified value is less than a maximum value)\n- **Guard.LessThanOrEqualTo** (throws if specified value is less than or equal to a maximum value)\n- **Guard.GreaterThan** (throws if specified value is greater than a minimum value)\n- **Guard.GreaterThanOrEqualTo** (throws if specified value is greater than or equal to a minimum value)\n- **Guard.NotOutOfLength** (throws if specified value is out of the range)\n- **Guard.IsPositive** (throws if specified value is not positive)\n- **Guard.NotNegative** (throws if specified value is negative)\n- **Guard.NotZero** (throws if specified value is zero)\n- **Guard.PagingArgsValid** (throws if specified value is out of the page range)\n\nMisc\n- **Guard.IsEqual** (throws if ...)\n- **Guard.Against** (throws if ...)\n- **Guard.Cast** (throws if ...)\n- **Guard.IsTrue** (throws if ...)\n- **Guard.IsFalse** (throws if ...)\n- **Guard.GetParamName** (throws if ...)\n\nType\n- **Guard.IsFunction** (throws if ...)\n- **Guard.IsEnumType** (throws if ...)\n- **Guard.InheritsFrom** (throws if ...)\n- **Guard.Implements** (throws if ...)\n- **Guard.IsSubclassOf** (throws if ...)\n- **Guard.IsTypeOf** (throws if ...)\n- **Guard.HasDefaultConstructor** (throws if ...)\n\n\n## Usage\n\n```C#\npublic class CustomerController : Controller\n{\n    [HttpPost]\n    [Route(\"add-customer\")]\n    public IActionResult AddCustomer(Customer customer)\n    {\n        // class (custom type) guard\n        Guard.NotNull(customer, nameof(customer));\n\n        // property guard\n        Guard.NotNullOrEmpty(customer.Username, nameof(customer.Username));\n\n        // explicit message\n        Guard.NotNullOrEmpty(customer.FirstName, nameof(customer.FirstName), \"Firstname is required\");\n\n        // int range guard\n        Guard.GreaterThanOrEqualTo(10, 50, nameof(customer.Age));\n\n        // bool guard\n        Guard.IsFalse(customer.IsActive, nameof(customer.IsActive));\n\n        return Ok();\n    }\n\n    [HttpGet]\n    [Route(\"find-customer\")]\n    public IActionResult FindCustomer(string username)\n    {\n        Guard.NotNullOrEmpty(username, nameof(username));\n\n\n        return Ok();\n    }\n\n    [HttpGet]\n    [Route(\"get-customer-by-age\")]\n    public IActionResult GetCustomerByAge(int age)\n    {\n        // int range guard\n        Guard.GreaterThanOrEqualTo(10, 50, nameof(age));\n\n        return Ok();\n    }\n\n    [HttpGet]\n    [Route(\"get-active-customers\")]\n    public IActionResult GetActiveCustomers(bool isActive)\n    {\n        // bool guard\n        Guard.IsFalse(isActive, nameof(isActive));\n\n\n        return Ok();\n    }\n\n    [HttpPost]\n    [Route(\"add-customer-T\")]\n    public IActionResult AddCustomer\u003cT\u003e(T customer) where T : class\n    {\n        // generic type guard\n        Guard.NotNull\u003cT\u003e(customer, nameof(customer));\n\n        return Ok();\n    }\n\n    [HttpPost]\n    [Route(\"add-customers\")]\n    public IActionResult AddCustomers(List\u003cCustomer\u003e customers)\n    {\n        // list guard\n        Guard.NotNull(customers, nameof(customers));\n\n\n        return Ok();\n    }\n}\n```\n\n\n\n\n\n\n\n---\n\n\n\n## Support :telephone:\n\u003e Reach out to me at one of the following places!\n\n- Email :envelope: at \u003ca href=\"mailto:toaashishpatel@gmail.com\" target=\"_blank\"\u003e`toaashishpatel@gmail.com`\u003c/a\u003e\n- NuGet :package: at \u003ca href=\"https://www.nuget.org/profiles/iamaashishpatel\" target=\"_blank\"\u003e`@iamaashishpatel`\u003c/a\u003e\n\n\n\n## Authors :boy:\n\n* **Ashish Patel** - [A-Patel](https://github.com/a-patel)\n\n\n##### Connect with me\n\n| Linkedin | GitHub | Facebook | Twitter | Instagram | Tumblr | Website |\n|----------|----------|----------|----------|----------|----------|----------|\n| [![linkedin](https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/svgs/fi-social-linkedin.svg)](https://www.linkedin.com/in/iamaashishpatel) | [![github](https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/svgs/fi-social-github.svg)](https://github.com/a-patel) | [![facebook](https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/svgs/fi-social-facebook.svg)](https://www.facebook.com/aashish.mrcool) | [![twitter](https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/svgs/fi-social-twitter.svg)](https://twitter.com/aashish_mrcool) | [![instagram](https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/svgs/fi-social-instagram.svg)](https://www.instagram.com/iamaashishpatel/) | [![tumblr](https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/svgs/fi-social-tumblr.svg)](https://iamaashishpatel.tumblr.com/) | [![website](https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/svgs/fi-social-blogger.svg)](http://aashishpatel.co.nf/) |\n| | | | | | |\n\n\n\n## Donations :dollar:\n\n[![Buy Me A Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/iamaashishpatel)\n\n\n\n## License :lock:\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa-patel%2Flitexguard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa-patel%2Flitexguard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa-patel%2Flitexguard/lists"}