Stef.Validation 0.2.0-preview-01
Stef.Validation
Guard methods for argument validation (NotNull, NotEmpty, ...)
Usage example Stef.Validation
using Stef.Validation;
public Person(string name, int age)
{
Guard.NotNullOrEmpty(name, nameof(name));
Guard.NotNullOrEmpty(name); // It's also possible to omit the `nameof(...)`-statement because CallerArgumentExpression is used internally.
Guard.Condition(age, a => a > 0, nameof(age));
}
Usage example Stef.Validation.Options
This package provides an extension method to validate options using data annotations. It is useful when you want to ensure that your options are correctly configured at startup.
Define options class
public class MyOptions
{
[Required] // This attribute ensures that the Name property is not null or empty
public required string Name { get; init; }
}
Validate options
using Stef.Validation.Options;
public static IServiceCollection Register(this IServiceCollection services, MyOptions options)
{
Guard.NotNull(services);
Guard.NotNull(options);
// Add the options to the service collection. And throw an exception if the options are not valid.
services.AddOptionsWithDataAnnotationValidation(options);
}
Showing the top 20 packages that depend on Stef.Validation.
Packages |
---|
ModelContextProtocol-SemanticKernel
Microsoft SemanticKernel integration for the ModelContextProtocol (official C# SDK). Enables seamless use of MCP tools as AI functions.
|
Stef.Validation.Options
TOptions validation using DataAnnotations.
|
See ReleaseNotes.md
.NET Framework 2.0
- LinqBridge (>= 1.3.0)
.NET Framework 3.5
- No dependencies.
.NET Framework 4.0
- No dependencies.
.NET Standard 1.0
- NETStandard.Library (>= 1.6.1)
.NET Standard 1.3
- NETStandard.Library (>= 1.6.1)
.NET Core 3.1
- No dependencies.
.NET 5.0
- No dependencies.
.NET 6.0
- No dependencies.
.NET Standard 2.0
- No dependencies.
.NET Standard 2.1
- No dependencies.
Version | Last updated |
---|---|
0.2.0 | 06/15/2025 |
0.2.0-preview-02 | 06/15/2025 |
0.2.0-preview-01 | 06/15/2025 |
0.1.1 | 05/30/2025 |
0.1.0 | 06/08/2025 |
0.0.4 | 06/08/2025 |
0.0.3 | 06/08/2025 |
0.0.2 | 06/08/2025 |
0.0.1 | 06/08/2025 |