I've got a common validation scenario where I need to check for a duplicate email or screen name on user signup which requires hitting the database. If the email or screen name entered is invalid according to a prior rule, there's no reason to hit the database to check for a dupe account.
I'm not sure how to do this. The closest I could get is to create a custom attribute that hits the database and put it at the end of a chain of checks with the cascade mode set to stop on the first failure.
However, I'd have to hit the database twice, once for email and once for the screen name. It would be nice to just hit the database once inside the validator, get all the info I need and then do my checks with that and only if no previous rules have failed.
I can't do that though because there's no way I can see to access the current IsValid state within the validator.
Is there any way to get at the current IsValid state inside a validator and if not, any ideas on how to accomplish this without multiple and unnecessary database hits?
Thanks!