Validation via aspect (should be attributes)

The ValidationAspects library defines an Extension method on object:

public static ValidationResult Validate(this object instance);

This method uses attributes like

[GreaterThan] and [ValidationMethod]

To create a ValidationResult with validation errors. So you can validate any object and all the validation rules defined on that object with be tested.

Using PostSharp with these aspect enables throwing validation expections on setter.

  • No labels