The accurate and reliable rails url validator (Rails 4). Valid Url gem provides you with the ability to smart and easy validate URL.
Add it to your Gemfile:
gem 'valid_url'
Run the following command to install it:
bundle install
class WebSite < ActiveRecord::Base
validates :url, :url => true
end
- Allow using http, https and schema-less urls. (will be configurable in future)
- Checking domain zones (The Root Zone Database)
- Allow and validate ip-based hostnames.
- Checking name space specifications and terminology (RFC 1034, Section 3.1).
- Checking hostname characters.
Despite the fact that there are several good url validation gems on github none of them could satisfy strict standards and rules.
The highest test coverage with more than a hundred different valid and invalid url examples.
Special thanks go to the Addressable gem author and contributors. However, there are plans to abandon third-party libraries.
This projected is licensed under the terms of the MIT license.