summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2017-09-09 16:54:50 +0200
committerHarald Eilertsen <haraldei@anduin.net>2017-09-09 16:56:06 +0200
commit032d46f65ac3bbfe5c05f96e6b68d0dfe2a4aa3d (patch)
tree3c9d5c6ee730730c8e281def9582974c1ec134de /lib
parenta147a9a6c761d5d867c24bbea09f4d558591e07c (diff)
downloadnorsk-urskog-registrations-032d46f65ac3bbfe5c05f96e6b68d0dfe2a4aa3d.tar.gz
norsk-urskog-registrations-032d46f65ac3bbfe5c05f96e6b68d0dfe2a4aa3d.tar.bz2
norsk-urskog-registrations-032d46f65ac3bbfe5c05f96e6b68d0dfe2a4aa3d.zip
Split contact address into street, postcode and city.
Diffstat (limited to 'lib')
-rw-r--r--lib/contact.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/contact.rb b/lib/contact.rb
index 5e6c475..ffa33bf 100644
--- a/lib/contact.rb
+++ b/lib/contact.rb
@@ -1,23 +1,33 @@
class Contact
- attr_reader :name, :addr, :phone, :email
+ attr_reader :name, :street, :postcode, :city, :phone, :email
def initialize(params = nil)
if params
@name = params['name']
- @addr = params['addr']
+ @street = params['street']
+ @postcode = params['postcode']
+ @city = params['city']
@phone = params['phone']
@email = params['email']
end
end
+ def addr
+ "#{@street}, #{@postcode} #{@city}"
+ 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"
+ if @postcode.nil? || @postcode.strip.empty?
+ errors << "Du må oppgi et gyldig postnr."
+ end
+
+ if @city.nil? || @city.strip.empty?
+ errors << "Du må oppgi poststed."
end
if @phone.nil? || @phone.strip.empty?