Smart Validation System
EasyValidate's intelligent validation context system provides automatic dependency injection and type-safe access to current model instances. Build sophisticated validation logic with compile-time safety and analyzer enforcement.
Smart Validation in Action
See how EasyValidate's intelligent context system provides automatic dependency injection and type-safe model access.
Smart System Features
EasyValidate's intelligent features make building complex validation logic simple and type-safe.
Analyzer Enforcement
EasyValidate analyzers enforce type safety and guide developers to correct implementations.
// ❌ This will cause compiler error
public class Product : IGenerate // Missing IProductContext!
{
[ValidatePrice] // Uses ValidationContext with IProductContext
public decimal Price { get; set; }
}
// ✅ Correct implementation
public class Product : IGenerate, IProductContext
{
[ValidatePrice]
public decimal Price { get; set; }
public string Category { get; set; } // Required by IProductContext
public bool IsOnSale { get; set; } // Required by IProductContext
}
Analyzer Message:
Model must implement IProductContext interface required by ValidationContext in ValidatePriceAttribute
public class InvalidValidationAttribute : Attribute
{
[ValidationContext]
public ISomeInterface? Context { get; set; } // Model must implement this
}
// ❌ Model doesn't implement ISomeInterface
public class MyModel : IGenerate
{
[InvalidValidation]
public string Value { get; set; }
}
Analyzer Message:
MyModel must implement or inherit ISomeInterface to use InvalidValidationAttribute