Skip to content

n0ts/validates_format_of_url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

validates_format_of_url plugin

This plugin provides a validator for URL. 
This plugin inspired from "Validating the format of an URL with Rails" (http://www.simonecarletti.com/blog/2009/04/validating-the-format-of-an-url-with-rails/).

==== Installation

Install RAIS_ROOT/vendor/plugins directory.


==== Usage

class Hoge < ActiveRecord:Base
  validates_format_of_url :url
end

or

class Hoge < ActiveRecord::Base
  validate :check_url

  def check_url
    if validates_format_of_url(url) == false
      errors.add(:url, 'URL is invalid.')
    end
  end
end


==== Configurations

* :schemes - An array of allowed schemes to match against (default is [:http, :https])
* :message - A custom error message (default is: "is invalid").

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages