Browse the Ruby on Rails Community.

You are here: Browse Railsplugins Http Url Validation Improved

Http Url Validation Improved

HTTP URL Validation is a Rails plugin that allows you to validate a URL entered in a form. It validates if the URL exists by hitting it with a HEAD request. There’s the option to also check that the URL returns content of a specified type. Here’s how you can use it your model:

Check for content type: validates_http_url :url, :content_type => “text/html”

Do not check for content type, just make sure the site is accessible: validates_http_url :website

Make sure there is a DNS entry for a domain validates_http_domain :domain
  1. Domain must be in ‘www.site.com’ for or ‘site.com’ form. No http://, no path.
This example will make sure the value entered for the URL field points to a publicly accessible HTML page, and the photo field points to an image: validates_http_url :image_url, :content_type => “image”
  1. :content_type checks for a matching substring, so any image will validate

========================

Bug reports and feedback are always welcome. Please send them to hardware.hank {at} gmail [.] com

You can also visit http://www.ccjr.name/blog/2006/01/25/http-url-validator/ and post a comment.

NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly

Users


See all 3 member details


Membership

+ Join this railsplugin

Record Maintainer

'None'