# ardalis/GuardClauses

A simple package with guard clause extensions.

Repository: https://github.com/ardalis/GuardClauses
Canonical: https://ross.abutalabs.com/products/guardclauses
Language: C#
License: MIT
License Family: permissive
Topics: guard, guard-clause, guard-clauses, clean-code, dotnet, dotnet-core, clean-architecture, pattern, patterns, design-patterns, hacktoberfest
Last push: 2026-08-24T12:23:41+00:00

## Health v2 (maintenance only)
Score: 67/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 8, longevity 100
- inputs: {"age_days": 3277, "days_push": 9, "days_rel": 702, "gap_med": null, "n_releases_24m": 1}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 3314, forks 296 (observed 2026-08-28T04:07:56.074924+00:00)

## What it is
A small, extensible C# library providing guard clause extension methods for fail-fast argument validation. It offers checks like null, empty, out-of-range, and format validation, and can be extended with custom guards.

## Use cases
- validate method arguments in c#
- fail fast on null or empty inputs
- add guard clauses to dotnet constructors
- validate argument ranges and formats
- throw notfound exceptions for id lookups
- write cleaner code without verbose if-throw blocks

## When to choose
- you write .NET code and want concise, expressive argument validation
- you follow clean architecture or clean code practices and want a lightweight dependency
- you need extensible guard clauses with custom checks

## When to avoid
- you need full data annotation or fluent validation of complex object graphs
- you are not working in the .NET ecosystem

## Facets
- artifact type: library
- maturity: stable
- function: error-handling, developer-tools
- domain: developer-tools, programming-languages
- platform: dotnet, cross-platform
- tags: guard-clauses, clean-code, design-patterns, fail-fast, input-validation, nuget

## Member repositories
- ardalis/GuardClauses (main) score 67

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:07:56.074924+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:42:05.791312+00:00, confidence not recorded.
  - readme: https://github.com/ardalis/GuardClauses (fetched 2026-08-28T04:07:56.074924+00:00, sha da9e9f1146d8)
- Data as of 2026-08-30T08:39:29.467469+00:00.
