0.0
No commit activity in last 3 years
No release in over 3 years
Library for validating urls in Rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.1.2
>= 0
>= 0

Runtime

 Project Readme

Validates URL

This gem adds the capability of validating URLs to ActiveRecord and ActiveModel (Rails 3).

Installation

# add this to your Gemfile
gem "validate_url"

# and  run
sudo gem install validate_url

Usage

With ActiveRecord

class Pony < ActiveRecord::Base
  # standard validation
  validates :homepage, :url => true

  # with allow_nil
  validates :homepage, :url => {:allow_nil => true}

  # with allow_blank
  validates :homepage, :url => {:allow_blank => true}
end

With ActiveModel

class Unicorn
  include ActiveModel::Validations

  attr_accessor :homepage

  # with legacy syntax (the syntax above works also)
  validates_url :homepage, :allow_blank => true
end

I18n

The default error message is not valid url. You can pass the :message => "my custom error" option to your validation to define your own, custom message.

Contributing

Big thanks to Tanel Suurhans, Tarmo Lehtpuu, Steve Smith and all the contributors! We appreciate all your work on new features and bugfixes.

Credits

Validates URL is created and maintained by PerfectLine, LLC.

License

Validates URL is Copyright © 2010-2014 PerfectLine, LLC. It is free software, and may be redistributed under the terms specified in the LICENSE file.