summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2015-10-10 18:36:09 +0200
committerHarald Eilertsen <haraldei@anduin.net>2015-10-10 18:36:09 +0200
commit800f8b9ee333fa703b30e3761124428564456908 (patch)
treea4b56b38c22a7c1cc7ffe0007390e540e7913bbc /lib
parentd9696a5eb4aa8638b757ca95b4cc2a4d5b8ae4f6 (diff)
downloadnorsk-urskog-registrations-800f8b9ee333fa703b30e3761124428564456908.tar.gz
norsk-urskog-registrations-800f8b9ee333fa703b30e3761124428564456908.tar.bz2
norsk-urskog-registrations-800f8b9ee333fa703b30e3761124428564456908.zip
Validate presence of contact info when submitting form.
Diffstat (limited to 'lib')
-rw-r--r--lib/band.rb2
-rw-r--r--lib/contact.rb21
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/band.rb b/lib/band.rb
index 59e7541..8cd3535 100644
--- a/lib/band.rb
+++ b/lib/band.rb
@@ -45,6 +45,8 @@ class Band
errors << "Bandnavn mangler"
end
+ errors.concat(@contact.validate!)
+
if @songs.length <= 0
errors << "Du må ha med minst én låt!"
end
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