validate_as_url 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/validate_as_url.rb +9 -5
- data/validate_as_url.gemspec +1 -1
- metadata +1 -1
data/lib/validate_as_url.rb
CHANGED
@@ -15,16 +15,20 @@ module ValidateAsUrl
|
|
15
15
|
allow_nil: false,
|
16
16
|
allow_blank: false
|
17
17
|
}
|
18
|
-
opts = options.merge(default_options)
|
18
|
+
opts = options.merge(default_options) # merge the default options into the specified options, retaining all specified options
|
19
19
|
|
20
|
-
if opts[:allow_nil] == false
|
21
|
-
|
20
|
+
if opts[:allow_nil] == false
|
21
|
+
if url.nil?
|
22
|
+
return [ opts[:message_nil] ]
|
23
|
+
end
|
22
24
|
end
|
23
25
|
|
24
26
|
url = url.to_s.strip
|
25
27
|
|
26
|
-
if opts[:allow_blank]
|
27
|
-
|
28
|
+
if opts[:allow_blank] == false
|
29
|
+
if url.blank?
|
30
|
+
return [ opts[:message_blank] ]
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
unless url =~ /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix
|
data/validate_as_url.gemspec
CHANGED