views:

227

answers:

1

Hi,

I'm sending friends invitations and I want to validate email address using User.validates_format_of :email, except that User.email has a couple of other validations which I'm not really interested in.

So is there a way to run a single validation on a model or check if that specific validation has passed (without doing user.errors.include?(validation_message) )?

A: 

http://stackoverflow.com/questions/457239/is-there-a-way-to-validate-a-specific-attribute-on-an-activerecord-without-instan/457313#457313

Milan Novota
Thanks, but this solves the problem only partially, I still need to know which of email validations failed.
squil
You can modify my method easily to find out which validation failed via checking the error messages. Or am I on the wrong track here?
Milan Novota
You are right, except I didn't want to do this through error messages. I couldn't find another solution though, so thanks anyway :)
squil