A lightweight, production-ready tool to catch critical configuration issues before runtime. Validate your configuration files during application startup or in your CI/CD pipeline.
Quick links:
Misconfigured environments, missing connection strings, or wrong URLs can cause major issues after deployment.
SGuard.ConfigValidation helps you detect these problems early, preventing runtime failures and reducing debugging time.
- β
Multiple Validators:
required,min_len,max_len,eq,ne,gt,gte,lt,lte,in - β JSON & YAML Support: Load configuration and app settings from JSON and YAML files
- β
JSON Schema Validation: Validate
sguard.jsonagainst JSON Schema - β Custom Validator Plugins: Extend validation capabilities with custom validators
- β CLI Tool: Command-line interface for easy validation
- β Dependency Injection: Full DI support with extension methods
- β Security Features: Built-in DoS protection, path traversal protection, and resource limits
- β Performance Optimized: Caching, streaming, and parallel validation support
- β Multiple Output Formats: Console, JSON, and text file output
- β Comprehensive Testing: High test coverage with xUnit
This repository contains multiple projects:
-
SGuard.ConfigValidation - Core library (NuGet package)
- Full API documentation and usage examples
- See detailed README
-
SGuard.ConfigValidation.Console - CLI application
- Command-line tool for configuration validation
- See detailed README
-
SGuard.ConfigValidation.Test - Test suite
- Comprehensive unit and integration tests
# Clone the repository
git clone https://github.com/selcukgural/SGuard.ConfigValidation.git
cd SGuard.ConfigValidation
# Run validation
cd SGuard.ConfigValidation.Console
dotnet run -- validate --allusing Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SGuard.ConfigValidation.Extensions;
using SGuard.ConfigValidation.Services.Abstract;
var services = new ServiceCollection();
services.AddLogging(builder => builder.AddConsole());
services.AddSGuardConfigValidation();
var serviceProvider = services.BuildServiceProvider();
var ruleEngine = serviceProvider.GetRequiredService<IRuleEngine>();
var result = await ruleEngine.ValidateEnvironmentAsync("sguard.json", "prod");{
"version": "1",
"environments": [
{
"id": "prod",
"name": "Production",
"path": "appsettings.Production.json"
}
],
"rules": [
{
"id": "connection-string-rule",
"environments": ["prod"],
"rule": {
"id": "required-connection-string",
"conditions": [
{
"key": "ConnectionStrings:DefaultConnection",
"condition": [
{
"validator": "required",
"message": "Connection string is required"
},
{
"validator": "min_len",
"value": 10,
"message": "Connection string must be at least 10 characters"
}
]
}
]
}
}
]
}- .NET 8.0 (LTS)
- .NET 9.0
- .NET 10.0
- Core Library Documentation - Complete API reference, usage examples, and advanced features
- Console Application Documentation - CLI usage, environment management, and logging configuration
# Run all tests
dotnet test
# Run tests with coverage
dotnet test --collect:"XPlat Code Coverage" --results-directory:"./TestResults"SGuard.ConfigValidation includes built-in security features:
- DoS Protection: Resource limits prevent memory exhaustion
- Path Traversal Protection: Prevents access to files outside base directory
- Symlink Attack Protection: Validates symlinks to prevent unauthorized access
- Configurable Limits: Adjustable security limits via configuration
See Security Configuration for details.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or contributions, feel free to open an issue or pull request!