validates :customertype, :presence => true, :inclusion => { :in => ["person","company"] }
with_options :if => :is_person? do |person|
person.validates :email, :presence => true, :length => {:minimum => 5}, :format => {:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i}
end
def is_person?
self.customertype == "person"
end