locked
CustomValidation and resources RRS feed

  • Question

  • I am trying to build a small custom validation library to be used with RIA Services. I have a question regarding CustomValidation attribute. I have implemented a custom validation class and method and all is fine. But the CustomAttribute also accepts ErrorMessageResourceName and ErrorMessageResourceType. I have tried to use them but the resulting message is always the one I pass to the ValidationResult returned by the custom validation class/method. Is there actually a way to use resources along with CustomValidation attribute or is it some kind of "inheritance" that allows resource related parameter names to be defined in the custom validation attribute?

    Thanks in advance Kostas Christodoulou

    P.S. I don't know if this is the right place to post this (I have a feeling it's not) but couldn't find a more "appropriate" forum to post at.


    1+1 = 3 for large values of 1
    Wednesday, July 20, 2011 12:30 PM

Answers

  • Found the answer on my own. Passing an empty string in the ValidationResult does the work. Actually what I have ended up with is to versions of the same method IsValid and IsValidSilent. The first one if there is a validation issue returns a ValidationResult with a custom message. The second one returns a validation result with an empty string. Would be nice if one could pass a parameter instead of having to different methods, but it's something I can live with.
    1+1 = 3 for large values of 1
    Wednesday, July 20, 2011 1:05 PM