CustomValidator and GetComputedErrorMessage

Topics: User Forum
Jan 29, 2007 at 1:40 PM

Let me begin by saying that I think this is an excellent framework, I had a look around and I prefer it over all the others that I have seen (including the Enterprise Library 3.0 validation block).
I have a quick question though: I have just started using it and I am getting a NotImplementedException out of the GetComputedErrorMessage method in CustomRule class. I have seen that your sample uses a custom validator so I am asking myself if I am using the validator correctly or not. Am I doing something wrong that the default message is being generated (I am supplying a message myself).
Regarding the comment in the method (//TODO: automagically include the property name??) I think yes, that would be a great idea :)

Jan 30, 2007 at 9:38 AM
This discussion has been copied to Work Item 7786. You may wish to continue further discussion there.
Jan 30, 2007 at 9:46 AM
Sorry about that.
I purposefully left that as a todo as I could not decide how to intelligently generate the error message. I have gone with a generic error message.
protected override string GetComputedErrorMessage(string tokenizedMemberName)
return string.Format("The member '{0}' is invalid.", tokenizedMemberName);

You can override this by setting CustomValidatorAttribute.ErrorMessage.

If you download the latest source you will get the fix.

Thanks for reminding me.
Jan 31, 2007 at 10:10 AM
Thanks! that's great.