How to create a custom validator

i was wondering how can i create my own custom validates_ function. e.g.
i am validating email adresses on a lot of places and would like to
achieve the following

class User
validates_email :email
end

does some has any hints?

with the same technique i would also like to do the following

class User
strip_attributes :firstname, :lastname
end

this would automatically ensure that the attributes firstname and
lastname are stored always without preceeding and trailing spaces.
thanks for your help…

On Nov 24, 9:12 am, Michal G. <rails-mailing-l…@andreas-
s.net> wrote:

with the same technique i would also like to do the following

class User
strip_attributes :firstname, :lastname
end

this would automatically ensure that the attributes firstname and
lastname are stored always without preceeding and trailing spaces.
thanks for your help…

Posted viahttp://www.ruby-forum.com/.

these are good

http://www.railsjitsu.com/ruby-on-rails/writing-your-own-custom-validators/
http://paulsturgess.co.uk/articles/show/33-how-to-write-custom-validation-in-ruby-on-rails

On Nov 24, 9:12 am, Michal G. <rails-mailing-l…@andreas-
s.net> wrote:

with the same technique i would also like to do the following

class User
strip_attributes :firstname, :lastname
end

this would automatically ensure that the attributes firstname and
lastname are stored always without preceeding and trailing spaces.
thanks for your help…

Posted viahttp://www.ruby-forum.com/.

better no 404

http://www.railsjitsu.com/writing-your-own-custom-validators

thanks … this one is exactly what i need.

http://www.railsjitsu.com/writing-your-own-custom-validators