Skip to content

Instantly share code, notes, and snippets.

@LTe
Created November 23, 2010 15:00
Show Gist options
  • Save LTe/711882 to your computer and use it in GitHub Desktop.
Save LTe/711882 to your computer and use it in GitHub Desktop.
FIELDS = [:about_url, :feedback_url, :terms_of_service_url, :privacy_policy_url, :support_url, :contact_url]
self.with_options(:with => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix ) do |url|
FIELDS.each do |field|
url.validates_format_of field, :if => lambda{ |val| !val.send(field).blank? }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment