validate_url 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/README.markdown +58 -0
  2. metadata +2 -2
data/README.markdown CHANGED
@@ -0,0 +1,58 @@
1
+ # ValidateUrl
2
+
3
+ This gem adds the capability of validating URLs to ActiveRecord (Rails 2) and ActiveModel (Rails 3).
4
+
5
+ ### Installation
6
+ # add this to your Gemfile (Rails 3)
7
+ gem "validate_url"
8
+
9
+ # add this to environment.rb
10
+ config.gem "validate_url"
11
+
12
+ # and then run
13
+ rake gems:install
14
+
15
+ # or just run
16
+ sudo gem install validate_url
17
+
18
+ ### Usage
19
+
20
+ #### With ActiveRecord in Rails 3
21
+ class Pony < ActiveRecord::Base
22
+ # standard validation
23
+ validates :homepage, :url => true
24
+
25
+ # with allow_nil
26
+ validates :homepage, :url => {:allow_nil => true}
27
+
28
+ # with allow_blank
29
+ validates :homepage, :url => {:allow_blank => true}
30
+ end
31
+
32
+ #### With ActiveRecord in Rails 2
33
+ class Pony < ActiveRecord::Base
34
+ validates_url :homepage, :allow_blank => true
35
+ end
36
+
37
+ #### With ActiveModel
38
+ class Unicorn
39
+ include ActiveModel::Validations
40
+
41
+ attr_accessor :homepage
42
+
43
+ # with legacy syntax (the syntax above works also)
44
+ validates_url :homepage, :allow_blank => true
45
+ end
46
+
47
+ #### I18n
48
+
49
+ The default error message `is not valid url`.
50
+ You can pass the `:message => "my custom error"` option to your validation to define your own, custom message.
51
+
52
+ ## Authors
53
+
54
+ **Tanel Suurhans** (<http://twitter.com/tanelsuurhans>)
55
+ **Tarmo Lehtpuu** (<http://twitter.com/tarmolehtpuu>)
56
+
57
+ ## License
58
+ Copyright 2010 by PerfectLine LLC (<http://www.perfectline.co.uk>) and is released under the MIT license.
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tanel Suurhans