Hi Bryan;
I agree that the Verification chapter needs some work. We have made that a priority to improve the Wiki in the next few months.
As for your question, instead of creating a DelegateVerifier, we should use a PropertyValueVerifier abstract class to create the generic GUID.Empty verifier. The PropertyValueVerifier abstract class is useful when you need to create a custom verifier when comparing objects or values. You can refer to our API Documentation --> IdeaBlade.Validation namespace for more useful Verifier classes.
Here's the code to create your generic GUID.Empty verifier:
private static Verifier CheckForGUIDEmptyVerifier(Type entityType, string propertyName) {
Verifier v = new GUIDEmptyVerifier(entityType, propertyName);
v.VerifierArgs.ErrorMessageInfo.ErrorMessage =
String.Format("{0} cannot be blank", propertyName);
return v;
}
public class GUIDEmptyVerifier : PropertyValueVerifier {
public GUIDEmptyVerifier(Type pType, String propertyName, String displayName = null, bool? shouldTreatEmptyStringAsNull = null)
: base(new PropertyValueVerifierArgs(pType, propertyName, false, displayName, shouldTreatEmptyStringAsNull)) {
}
protected override VerifierResult VerifyValue(object itemToVerify, object valueToVerify,
TriggerContext triggerContext, VerifierContext verifierContext) {
var aGUID = (Guid)valueToVerify;
var result = (aGUID != Guid.Empty);
return new VerifierResult(result);
}
}