?Conditional validation skipping?

Hey,

I have validation that I need to be able to bypass depending on a cookie
that the user might have.

My problem is for most users, they have to have a .edu or .com email
address. So I wrote that into the validation.

But if a certain cookie is set, I want to allow them to register with
any email address, and still run the other validations (uniqueness of
email, etc.)

Does anyone have any information on how to do this?

USER MODEL
validates_presence_of :first_name, :last_name, :email, :password
validates_uniqueness_of :email
validates_format_of :email,
:with => %r{.(edu|com)$}i,
:message => “Must be a valid email address”

On Nov 30, 2007 4:15 PM, Joe P. [email protected] wrote:

email, etc.)

Does anyone have any information on how to do this?

USER MODEL
validates_presence_of :first_name, :last_name, :email, :password
validates_uniqueness_of :email
validates_format_of :email,
:with => %r{.(edu|com)$}i,
:message => “Must be a valid email address”

Maybe use a filter in the controller that does registration. Try the
rails list for more help:
http://groups.google.com/group/rubyonrails-talk
or
http://www.ruby-forum.com/forum/3
on ruby-forum.

-A