How do I get my custom requiredif attribute to prevent other attributes from firing
- by user1757804
I'm working on an MVC application.
I've decorated a property with EqualTo found here: http://dataannotationsextensions.org/EqualTo/Create
As well as a custom RequiredIf attribute as suggested here: http://blogs.msdn.com/b/simonince/archive/2011/02/04/conditional-validation-in-asp-net-mvc-3.aspx
My issue is that even when the field is supposed to be required and isn't the EqualTo logic is firing. So I get error messages saying the field is required but also that the field doesn't match.
If I replace the Requiredif with a regular Required only the Required message will show.
What I'm trying to figure out is how the EqualTo logic is prevented when combined with the Required attribute but not prevented when combined with my custom RequiredIf.
Any suggestions would be most appreciated, I've been racking my brain most of the day trying to figure out the mvc internals around Required.