-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
33 lines (21 loc) · 735 Bytes
/
Copy pathREADME
File metadata and controls
33 lines (21 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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").