If you use CSLA and use GUIDs as your unique identifiers you may have need to make them required for a particular object’s property. It isn’t as difficult to do as you might think and I will show you how to accomplish this by writing a custom validation rule.
I have an object that has two properties, a LineNumber and a ControlAccount. The ControlAccount property is represented by as ComboBox using the Id (GUID) as the SelectedValuePath and the Description as the DisplayMemberPath as displayed by my WPF UI. I don’t want to user to be able to add a record unless they select a Control Account.
As you can see the LineNumber is required and I am using the built-in CommonRules.StringRequired rule to add validation to the LineNumber property.
So now my problem is that CSLA doesn’t have a GuidRequired rule in its CommonRules class for me to use. So I will have to write my own.
Now I can use this custom rule to add a required GUID validation rule to my object on my AccountIdProperty.
Now that my rule has been added to my object, my WPF UI will now pickup the new validation rule.