This project is read-only.
Project description
A small validation framework that adresses some issues with the default WPF implementation of validation and extends the default validationrules with new validationrules.

See for a complete description.

WPF offers some rather good stuff when it comes to applying validation to binding expressions. However it isn’t complete in my opinion and could use some kind of extension to make it even easier and more effective to use in an application.
There are a couple of things I noticed when working with validation in WPF:
  • It is not possible to check for binding validation failures. You need to manually check all bound values for validity, even if you have validation rules for them.
  • Validation rules are not triggered if the binding value hasn’t been changed. This may sound weird, but if you have a way of checking the validation rules it still doesn’t work because validation rules aren’t triggered when the binding value hasn’t been changed. This results in incorrect behavior.
  • The range of validation rules is limited. WPF offers only one validation rule out of the box. This is the ExceptionValidationRule. It is one however that you don’t want to miss, since it allows to catch exceptions that otherwise cause the application to crash.

I created a small framework to resolve these issues, I opted for validating using validation rules instead of the IErrorInfo that others have written about. I did this because I wanted more flexibility, so that I’m able to not only validate rich business objects, but also validate simple bindings.

The following features are offered by the framework:
  • A decorator to mark window/page/usercontrol content for validation.
  • Several new validationrules
    • RequiredValidationRule
    • LengthValidationRule
    • RangeValidationRule
    • RegexValidationRule
    • ValidationRuleBase

ValidationRuleBase allows for easy construction of new validation rules and contains a property to specify a default errormessage for when the validation rule fails.

More information
For information on how to use and modify the default validation features in WPF:
For information on the new DataValidationRule in WPF 3.5:
For more details on the validation framework:

Last edited Apr 12, 2008 at 8:46 PM by WMeints, version 5