Incorporating multiple validation techniques
Now that we've had a good look at the two validation interfaces, the data annotation attributes and the ability to validate with different levels, let's take a look at how we can amalgamate these different techniques together.
Let's create a BaseNotifyValidationModel
class by copying what we have in our previous implementation, to incorporate these new additions. First, we need to add some extra using directives to the ones used in the previous implementation:
using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel.DataAnnotations; using CompanyName.ApplicationName.DataModels.Enums;
Next, we need to add our validationLevel
and errors
fields:
private ValidationLevel validationLevel = ValidationLevel.Full; protected ObservableCollection<string> errors = new ObservableCollection<string>();
We need to add a constructor, in which we attach the ExternalErrors_CollectionChanged...