Method: Formbuilder::ResponseFieldWebsite#validate_response

Defined in:
app/models/formbuilder/response_field_website.rb

#validate_response(value) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'app/models/formbuilder/response_field_website.rb', line 31

def validate_response(value)
  require 'uri'

  # add http if not present
  value = "http://#{value}" unless value[/^http:\/\//] || value[/^https:\/\//]

  if !(value =~ URI::regexp) # this doesn't really validate, since almost *anything* matches
    "isn't a valid URL."
  end
end