ValidationAspects - AOP Validation Framework Using PostSharp - ASP.NET MVC and WPF
The release of ValidationAspects is quite timely given that I just finished a presentation to the Sarasota .NET Developer Group on Aspect-Oriented Programming AOP, called Introduction to Aspect-Oriented Programming.
ValidationAspects is a new validation framework that can be used with both the ASP.NET MVC Framework and WPF and uses PostSharp during the post build process to weave in the validation.
ValidationAspect Features include:
- Object Validation - Objects can be queried to determine if their state is valid against a set of validation rules. Validation messages and context of what/where validation failed is reported via a ValidationResult. An object can also be validated as a method pre-condition by registering an object validator against the method.
- Property Validation - Multi-Mode validation. The following modes can be enabled or disabled independantly to suit your chosen method of validation:
- Interception Validation - Validation is invoked when the property is set. If the validation fails, a validation exception will throw to ensure the model does not become invalid.
- State Validation - Validation is invoked when the object is validated. If the validation fails, the validation failure is added to the ValidationResult.
- Parameter Validation - Parameter validation checks the validity of the value as determined by code contracts and business rules. If the validation fails, a validation exception will throw to ensure the model does not become invalid.
- Real-time augmentation / replacement - Validation can be changed programmatically or via Xaml configuration.
- AOP - ValidationAspects are applied to your models by PostSharp. There are no base classes to derive from or interfaces to explicitly implement.
- Custom Validators - Implement new validators easily with minimal code with lambda syntax.
- Strongly-typed validation targets - Compile-time checking ensures validation is correctly declared - you can't declare a numeric validator to validate a string. Validators are implemented to target certain types. Incorrectly declared validators applied at run-time fail fast.
- Integration - Support for WPF and asp.net / asp.net MVC (via xVal ). Silverlight coming soon.
- Localization - Validation exception messages can be customized with message formatting functions.
- TDD'd - Near 100% code coverage from hundreds of unit tests.
Learn more here.
Validation Tutorials
Tags:
AOP,
MVC,
PostSharp,
WPF