Data validation goes hand in hand with data input forms and is essential to promote clean, usable data. While the UI controls in WPF can automatically validate that entered values match the type of their data bound properties, they cannot validate for the correctness of the entered data.
For example, a TextBox control that is data bound to an integer may highlight an error if a user entered a non-numeric value, but it wouldn't validate that the entered number contained the correct number of digits, or that the first four digits were appropriate for the type of credit card specified.
In order to validate these types of data correctness when using MVVM, we'll need to implement one of the .NET validation interfaces. In this chapter, we'll thoroughly examine the available interfaces, looking at a number of implementations and...