Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def validate_personal_questions(post)
- error_messages = ''
- if post[:postal_code].empty? or !PostalCodeService.is_valid_postal_code?(post[:postal_code])
- error_messages = 'Please enter a valid postal code '
- else
- if post[:term].nil?
- error_messages = 'Select a 3 or 5 year term. '
- else
- if post[:estimate].empty? and post[:gas_used].empty?
- error_messages = 'Please enter a value for Option A or Option B'
- end
- end
- end
- if error_messages.empty?
- if !post[:estimate].empty? and !post[:gas_used].empty?
- error_messages = 'You can only fill in option A or B. '
- else
- if !(post[:estimate].empty?) and (post[:estimate].to_i < 1)
- error_messages = 'Make sure you put in a proper value into estimate. '
- end
- if !(post[:gas_used].empty?) and (post[:gas_used].to_i < 1)
- error_messages = 'Make sure you put in a proper value into the gas used field. '
- end
- end
- end
- return error_messages
- end
Add Comment
Please, Sign In to add comment