views:

128

answers:

1

How can I override the IsValid property?

I have a model that's validating as false. I have a custom ValidationAttribute on the model and I'd like to set the IsValid flag for the whole model under certain circumstances.

Is this possible?

A: 

You can implement IDataErrorInfo on your model and apply model-wide validation.

This page has some information about iplementing the IDataErrorInfo Interface, about 2/3 of the way down under the heading "mplementing the IDataErrorInfo Interface"

Mac
Not, in this instance, what I was after. I know that the answer you gave to http://stackoverflow.com/questions/2649581/custom-validationattribute-test-against-whole-model was correct but now I just want to override the isvalid flag on the whole model
griegs
I don't believe you can change IsValid directly. If you want to override the ValidationAttribute, but then sometimes turn it off, you might be trying to use a validation attribute where it's not appropriate.
Mac
Hmmm, you could be right. I do seem to be having lots of trouble overriding the value.
griegs