blob: 5e6c475c5de26f2961313950196c9482cb5a05e4 (
plain) (
tree)
|
|
class Contact
attr_reader :name, :addr, :phone, :email
def initialize(params = nil)
if params
@name = params['name']
@addr = params['addr']
@phone = params['phone']
@email = params['email']
end
end
def validate!
errors = []
if @name.nil? || @name.strip.empty?
errors << "Du må oppgi en kontaktperson"
end
if @addr.nil? || @addr.strip.empty?
errors << "Du må oppgi en kontaktadresse"
end
if @phone.nil? || @phone.strip.empty?
errors << "Du må oppgi et telefonnummer"
end
if @email.nil? || @email.strip.empty?
errors << "Du må oppgi en epostadresse"
end
errors
end
end
|