You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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