summaryrefslogtreecommitdiffstats
path: root/lib/contact.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/contact.rb')
-rw-r--r--lib/contact.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/contact.rb b/lib/contact.rb
index 0d87012..5e6c475 100644
--- a/lib/contact.rb
+++ b/lib/contact.rb
@@ -9,4 +9,25 @@ class Contact
@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