Guest User

Untitled

a guest
Jul 15th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. def validate_personal_questions(post)
  2. error_messages = ''
  3.  
  4. if post[:postal_code].empty? or !PostalCodeService.is_valid_postal_code?(post[:postal_code])
  5. error_messages = 'Please enter a valid postal code '
  6. else
  7. if post[:term].nil?
  8. error_messages = 'Select a 3 or 5 year term. '
  9. else
  10. if post[:estimate].empty? and post[:gas_used].empty?
  11. error_messages = 'Please enter a value for Option A or Option B'
  12. end
  13. end
  14. end
  15.  
  16. if error_messages.empty?
  17. if !post[:estimate].empty? and !post[:gas_used].empty?
  18. error_messages = 'You can only fill in option A or B. '
  19. else
  20. if !(post[:estimate].empty?) and (post[:estimate].to_i < 1)
  21. error_messages = 'Make sure you put in a proper value into estimate. '
  22. end
  23. if !(post[:gas_used].empty?) and (post[:gas_used].to_i < 1)
  24. error_messages = 'Make sure you put in a proper value into the gas used field. '
  25. end
  26. end
  27. end
  28.  
  29. return error_messages
  30. end
Add Comment
Please, Sign In to add comment