Created
November 23, 2010 15:00
-
-
Save LTe/711882 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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