activevalidators 1.9.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -6
- data/README.md +2 -2
- data/activevalidators.gemspec +11 -8
- data/lib/active_model/validations/email_validator.rb +20 -15
- data/lib/active_model/validations/phone_validator.rb +2 -22
- data/lib/active_model/validations/postal_code_validator.rb +56 -2
- data/lib/active_model/validations/url_validator.rb +76 -7
- data/lib/activevalidators.rb +2 -0
- data/test/validations/email_test.rb +14 -14
- data/test/validations/phone_test.rb +9 -20
- data/test/validations/postal_code_test.rb +1 -1
- data/test/validations/url_test.rb +35 -0
- metadata +38 -16
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# ActiveValidators [![Travis](https://secure.travis-ci.org/
|
1
|
+
# ActiveValidators [![Travis](https://secure.travis-ci.org/franckverrot/activevalidators.png)](http://travis-ci.org/franckverrot/activevalidators)
|
2
2
|
|
3
3
|
# Description
|
4
4
|
|
@@ -98,4 +98,4 @@ Lots of improvements can be made:
|
|
98
98
|
|
99
99
|
## Copyright
|
100
100
|
|
101
|
-
Copyright (c) 2010-
|
101
|
+
Copyright (c) 2010-2012 Franck Verrot. MIT LICENSE. See LICENSE for details.
|
data/activevalidators.gemspec
CHANGED
@@ -1,22 +1,25 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |s|
|
3
|
-
s.name =
|
4
|
-
s.version = '
|
3
|
+
s.name = 'activevalidators'
|
4
|
+
s.version = '2.0.0'
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
|
-
s.authors = [
|
7
|
-
s.email = [
|
8
|
-
s.homepage =
|
6
|
+
s.authors = ['Franck Verrot', 'Paco Guzmán', 'Oriol Gual', 'Garrett Bjerkhoel', 'Renato Riccieri Santos Zannon', 'Brian Moseley']
|
7
|
+
s.email = ['franck@verrot.fr']
|
8
|
+
s.homepage = 'http://github.com/franckverrot/activevalidators'
|
9
9
|
s.summary = %q{Collection of ActiveModel/ActiveRecord validations}
|
10
10
|
s.description = %q{ActiveValidators is a collection of ActiveModel/ActiveRecord validations}
|
11
11
|
|
12
|
-
s.
|
13
|
-
|
12
|
+
s.required_ruby_version = '>= 1.9.2'
|
13
|
+
|
14
|
+
s.add_development_dependency 'bundler'
|
15
|
+
s.add_development_dependency 'minitest'
|
14
16
|
s.add_dependency 'rake' , '>= 0.8.7'
|
15
17
|
s.add_dependency 'activemodel' , '>= 3.0.0'
|
18
|
+
s.add_dependency 'phony' , '~> 1.7.4'
|
19
|
+
s.add_dependency 'countries' , '~> 0.8.2'
|
16
20
|
s.add_dependency 'mail'
|
17
21
|
s.add_dependency 'date_validator'
|
18
22
|
|
19
23
|
s.files = `git ls-files`.split("\n")
|
20
24
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
25
|
end
|
22
|
-
|
@@ -2,24 +2,29 @@ require 'mail'
|
|
2
2
|
module ActiveModel
|
3
3
|
module Validations
|
4
4
|
class EmailValidator < EachValidator
|
5
|
-
|
6
|
-
|
7
|
-
def validate_each(record,attribute,value)
|
8
|
-
opts = options.dup
|
9
|
-
opts[:strict] ||= false
|
10
|
-
|
5
|
+
def validate_each(record, attribute, value)
|
6
|
+
# takes from: https://github.com/hallelujah/valid_email
|
11
7
|
begin
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
mail = Mail::Address.new(value)
|
9
|
+
# We must check that value contains a domain and that value is an email address
|
10
|
+
valid = mail.domain && value.include?(mail.address)
|
11
|
+
|
12
|
+
if options[:only_address]
|
13
|
+
# We need to dig into treetop
|
14
|
+
# A valid domain must have dot_atom_text elements size > 1
|
15
|
+
# user@localhost is excluded
|
16
|
+
# treetop must respond to domain
|
17
|
+
# We exclude valid email values like <user@localhost.com>
|
18
|
+
# Hence we use m.__send__(tree).domain
|
19
|
+
tree = mail.__send__(:tree)
|
20
|
+
valid &&= (tree.domain.dot_atom_text.elements.size > 1)
|
21
|
+
else
|
22
|
+
valid &&= (mail.domain.split('.').length > 1)
|
23
|
+
end
|
24
|
+
rescue Exception => e
|
20
25
|
valid = false
|
21
26
|
end
|
22
|
-
record.errors.add(
|
27
|
+
record.errors.add attribute, (options[:message]) unless valid
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
@@ -2,28 +2,8 @@ module ActiveModel
|
|
2
2
|
module Validations
|
3
3
|
class PhoneValidator < EachValidator
|
4
4
|
def validate_each(record, attribute, value)
|
5
|
-
|
6
|
-
|
7
|
-
record.errors.add(attribute) if value.blank? || !matches_any?
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.known_formats
|
11
|
-
@@known_formats ||=
|
12
|
-
{:us => ["###-###-####", "##########", "###.###.####", "### ### ####", "(###) ###-####"],
|
13
|
-
:brazil => ["## ####-####", "(##) ####-####", "##########"],
|
14
|
-
:france => ["## ## ## ## ##"],
|
15
|
-
:uk => ["#### ### ####"]}
|
16
|
-
end
|
17
|
-
|
18
|
-
def matches_any?
|
19
|
-
false if @formats.nil? or not @formats.respond_to?(:detect)
|
20
|
-
@formats.detect { |format| @value.match(PhoneValidator.regexp_from format) }
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def self.regexp_from(format)
|
26
|
-
Regexp.new "^"+(Regexp.escape format).gsub('\#','\d')+"$"
|
5
|
+
country_code = Country.new(options[:country].to_s.upcase).country_code unless options[:country].blank?
|
6
|
+
record.errors.add(attribute, options[:message]) if value.blank? || ! (options[:country].blank? ? Phony.plausible?(value) : Phony.plausible?(value, cc: country_code) )
|
27
7
|
end
|
28
8
|
|
29
9
|
end
|
@@ -17,8 +17,62 @@ module ActiveModel
|
|
17
17
|
|
18
18
|
def self.known_formats
|
19
19
|
@@known_formats ||= {
|
20
|
-
'
|
20
|
+
'ad' => ['AD###', '###'],
|
21
|
+
'ar' => ['####', '@####@@@'],
|
22
|
+
'at' => ['####'],
|
23
|
+
'au' => ['####'],
|
24
|
+
'bg' => ['####'],
|
25
|
+
'be' => ['####'],
|
26
|
+
'bg' => ['####'],
|
27
|
+
'br' => ['#####-###', '########'],
|
28
|
+
'ca' => ['@#@ #@#', '@#@#@#'],
|
29
|
+
'ch' => ['####'],
|
30
|
+
'cz' => ['### ##', '#####'],
|
31
|
+
'de' => ['#####'],
|
32
|
+
'dk' => ['####'],
|
33
|
+
'dr' => ['#####'],
|
34
|
+
'sp' => ['#####'],
|
35
|
+
'fi' => ['#####'],
|
36
|
+
'fr' => ['#####'],
|
37
|
+
'uk' => ['@# #@@', '@## #@@', '@@# #@@', '@@## #@@', '@#@ #@@', '@@#@ #@@'],
|
38
|
+
'gf' => ['#####'],
|
39
|
+
'gl' => ['####'],
|
40
|
+
'gp' => ['#####'],
|
41
|
+
'gt' => ['#####'],
|
42
|
+
'hr' => ['HR-#####', 'H#####'],
|
43
|
+
'hu' => ['####'],
|
44
|
+
'in' => ['######'],
|
45
|
+
'ic' => ['###'],
|
46
|
+
'it' => ['#####'],
|
47
|
+
'jp' => ['###-####', '#######'],
|
48
|
+
'li' => ['####'],
|
49
|
+
'lk' => ['#####'],
|
50
|
+
'lt' => ['LT-#####', '#####'],
|
51
|
+
'lu' => ['####'],
|
52
|
+
'mc' => ['#####'],
|
53
|
+
'md' => ['MD-####'],
|
54
|
+
'mk' => ['####'],
|
55
|
+
'mq' => ['#####'],
|
56
|
+
'mx' => ['#####'],
|
57
|
+
'my' => ['#####'],
|
58
|
+
'nl' => ['#### @@', '####@@'],
|
59
|
+
'no' => ['####'],
|
60
|
+
'ph' => ['####'],
|
61
|
+
'pk' => ['#####'],
|
62
|
+
'pl' => ['##-###', '#####'],
|
63
|
+
'pm' => ['#####'],
|
21
64
|
'pt' => ['####', '####-###'],
|
65
|
+
'ru' => ['######'],
|
66
|
+
'se' => ['SE-#### ##', '#### ##', '######'],
|
67
|
+
'si' => ['SI- ####', 'SI-####', '####'],
|
68
|
+
'sk' => ['### ##', '#####'],
|
69
|
+
'sm' => ['4789#', '#'],
|
70
|
+
'th' => ['#####'],
|
71
|
+
'tr' => ['#####'],
|
72
|
+
'tr' => ['#####'],
|
73
|
+
'us' => ['#####', '#####-####'],
|
74
|
+
'wf' => ['#####'],
|
75
|
+
'za' => ['####']
|
22
76
|
}
|
23
77
|
end
|
24
78
|
|
@@ -30,7 +84,7 @@ module ActiveModel
|
|
30
84
|
private
|
31
85
|
|
32
86
|
def self.regexp_from(format)
|
33
|
-
Regexp.new "^"+(Regexp.escape format).gsub('
|
87
|
+
Regexp.new "^"+(Regexp.escape format).gsub(/[@#]/, '@' => '[[:alpha:]]', '#' => 'd')+"$"
|
34
88
|
end
|
35
89
|
end
|
36
90
|
end
|
@@ -1,15 +1,84 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
1
3
|
module ActiveModel
|
2
4
|
module Validations
|
5
|
+
|
6
|
+
# Public: Uses `URI.regexp` to validate URLs, by default only allows
|
7
|
+
# the http and https protocols.
|
8
|
+
#
|
9
|
+
# Examples
|
10
|
+
#
|
11
|
+
# validates :url, :url => true
|
12
|
+
# # => only allow http, https
|
13
|
+
#
|
14
|
+
# validates :url, :url => %w{http https ftp ftps}
|
15
|
+
# # => allow http, https, ftp and ftps
|
16
|
+
#
|
3
17
|
class UrlValidator < EachValidator
|
4
|
-
|
5
|
-
|
18
|
+
|
19
|
+
# Public: Creates a new instance, overrides `:protocols` if either
|
20
|
+
# `:with` or `:in` are defined, to allow for shortcut setters.
|
21
|
+
#
|
22
|
+
# Examples:
|
23
|
+
#
|
24
|
+
# validates :url, :url => { :protocols => %w{http https ftp} }
|
25
|
+
# # => accepts http, https and ftp URLs
|
26
|
+
#
|
27
|
+
# validates :url, :url => 'https'
|
28
|
+
# # => accepts only https URLs (shortcut form of above)
|
29
|
+
#
|
30
|
+
# validates :url, :url => true
|
31
|
+
# # => by default allows only http and https
|
32
|
+
#
|
33
|
+
# Raises an ArgumentError if the array with the allowed protocols
|
34
|
+
# is empty.
|
35
|
+
#
|
36
|
+
# Returns a new instance.
|
37
|
+
def initialize(options)
|
38
|
+
options[:protocols] ||= options.delete(:protocol) || options.delete(:with) || options.delete(:in)
|
39
|
+
super
|
6
40
|
end
|
7
|
-
|
8
|
-
|
41
|
+
|
42
|
+
# Internal: Ensures that at least one protocol is defined. If the protocols
|
43
|
+
# are empty it throws an ArgumentError.
|
44
|
+
#
|
45
|
+
# Raises ArgumentError if protocols is empty.
|
46
|
+
#
|
47
|
+
# Returns nothing.
|
48
|
+
def check_validity!
|
49
|
+
raise ArgumentError, "At least one URI protocol is required" if protocols.empty?
|
50
|
+
end
|
51
|
+
|
52
|
+
# Internal: Returns an array of protocols to use with the URI regexp.
|
53
|
+
# The default protocols are `http` and `https`.
|
54
|
+
#
|
55
|
+
# Returns the Array with the allowed protocols.
|
56
|
+
def protocols
|
57
|
+
Array.wrap(options[:protocols] || %w{http https})
|
58
|
+
end
|
59
|
+
|
60
|
+
# Internal: Constructs the regular expression to check
|
61
|
+
# the URI for the configured protocols.
|
62
|
+
#
|
63
|
+
# Returns the Regexp.
|
64
|
+
def uri_regexp
|
65
|
+
@uri_regexp ||= URI.regexp(protocols)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Internal: Tries to convert supplied string into URI,
|
69
|
+
# if not possible returns nil => invalid URI.
|
70
|
+
#
|
71
|
+
# Returns the URI or nil.
|
72
|
+
def as_uri(value)
|
73
|
+
URI.parse(value.to_s) rescue nil if value.present?
|
74
|
+
end
|
75
|
+
|
76
|
+
# Public: Validate URL, if it fails adds an error.
|
77
|
+
#
|
78
|
+
# Returns nothing.
|
9
79
|
def validate_each(record, attribute, value)
|
10
|
-
|
11
|
-
|
12
|
-
end
|
80
|
+
uri = as_uri(value)
|
81
|
+
record.errors.add(attribute) unless uri && value.to_s =~ uri_regexp
|
13
82
|
end
|
14
83
|
end
|
15
84
|
end
|
data/lib/activevalidators.rb
CHANGED
@@ -2,7 +2,7 @@ require 'test_helper.rb'
|
|
2
2
|
|
3
3
|
describe "Email Validation" do
|
4
4
|
describe "strict: true" do
|
5
|
-
|
5
|
+
|
6
6
|
it "accepts valid emails" do
|
7
7
|
subject = build_email_record({:email => 'franck@verrot.fr'}, {:strict => true})
|
8
8
|
subject.valid?.must_equal true
|
@@ -14,60 +14,60 @@ describe "Email Validation" do
|
|
14
14
|
subject.valid?.must_equal true
|
15
15
|
subject.errors.size.must_equal 0
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "accepts complete emails" do
|
19
19
|
subject = build_email_record({:email => 'Mikel Lindsaar (My email address) <mikel@test.lindsaar.net>'}, {:strict => true})
|
20
20
|
subject.valid?.must_equal true
|
21
21
|
subject.errors.size.must_equal 0
|
22
22
|
end
|
23
|
-
|
24
|
-
it "accepts
|
23
|
+
|
24
|
+
it "accepts email addresses without TLD" do
|
25
25
|
subject = build_email_record({:email => 'franck@verrotfr'}, {:strict => true})
|
26
26
|
subject.valid?.must_equal false
|
27
27
|
subject.errors.size.must_equal 1
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
describe "strict: false (default)" do
|
32
32
|
it "accepts valid emails" do
|
33
33
|
subject = build_email_record :email => 'franck@verrot.fr'
|
34
34
|
subject.valid?.must_equal true
|
35
35
|
subject.errors.size.must_equal 0
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
it "accepts valid emails" do
|
39
39
|
subject = build_email_record :email => 'franck@edu.verrot-gouv.fr'
|
40
40
|
subject.valid?.must_equal true
|
41
41
|
subject.errors.size.must_equal 0
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
it "accepts complete emails" do
|
45
45
|
subject = build_email_record :email => 'Mikel Lindsaar (My email address) <mikel@test.lindsaar.net>'
|
46
46
|
subject.valid?.must_equal true
|
47
47
|
subject.errors.size.must_equal 0
|
48
48
|
end
|
49
|
-
|
50
|
-
it "
|
49
|
+
|
50
|
+
it "rejects email addresses without TLD" do
|
51
51
|
subject = build_email_record :email => 'franck@verrotfr'
|
52
|
-
subject.valid?.must_equal
|
53
|
-
subject.errors.size.must_equal
|
52
|
+
subject.valid?.must_equal false
|
53
|
+
subject.errors.size.must_equal 1
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
describe "for invalid emails" do
|
58
58
|
it "rejects invalid emails" do
|
59
59
|
subject = build_email_record :email => 'franck.fr'
|
60
60
|
subject.valid?.must_equal false
|
61
61
|
subject.errors.size.must_equal 1
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
it 'rejects local emails' do
|
65
65
|
subject = build_email_record :email => 'franck.fr'
|
66
66
|
subject.email = 'franck'
|
67
67
|
subject.valid?.must_equal false
|
68
68
|
subject.errors.size.must_equal 1
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
it 'generates an error message of type invalid' do
|
72
72
|
subject = build_email_record :email => 'franck.fr'
|
73
73
|
subject.valid?.must_equal false
|
@@ -11,64 +11,53 @@ describe "Phone Validation" do
|
|
11
11
|
describe "when no country is given" do
|
12
12
|
it 'should validate format of phone with ###-###-####' do
|
13
13
|
subject = build_phone_validation true
|
14
|
-
subject.phone = '999-999-9999'
|
14
|
+
subject.phone = '1-999-999-9999'
|
15
15
|
subject.valid?.must_equal true
|
16
16
|
subject.errors.size.must_equal 0
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should validate format of phone with ##########' do
|
20
20
|
subject = build_phone_validation true
|
21
|
-
subject.phone = '
|
21
|
+
subject.phone = '19999999999'
|
22
22
|
subject.valid?.must_equal true
|
23
23
|
subject.errors.size.must_equal 0
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should validate format of phone with ###.###.####' do
|
27
27
|
subject = build_phone_validation true
|
28
|
-
subject.phone = '
|
28
|
+
subject.phone = '1999.999.9999'
|
29
29
|
subject.valid?.must_equal true
|
30
30
|
subject.errors.size.must_equal 0
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'should validate format of phone with ### ### ####' do
|
34
34
|
subject = build_phone_validation true
|
35
|
-
subject.phone = '
|
35
|
+
subject.phone = '1999 999 9999'
|
36
36
|
subject.valid?.must_equal true
|
37
37
|
subject.errors.size.must_equal 0
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should validate format of phone with (###) ###-####' do
|
41
41
|
subject = build_phone_validation true
|
42
|
-
subject.phone = '(999) 999-9999'
|
42
|
+
subject.phone = '1(999) 999-9999'
|
43
43
|
subject.valid?.must_equal true
|
44
44
|
subject.errors.size.must_equal 0
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
48
48
|
|
49
|
-
ActiveModel::Validations::PhoneValidator.known_formats.each do |country, formats|
|
50
|
-
describe "when given a :#{country} country parameter" do
|
51
|
-
formats.each do |format|
|
52
|
-
it "should validate format of phone with #{format}" do
|
53
|
-
subject = build_phone_validation :country => country
|
54
|
-
subject.phone = format.gsub('#','9')
|
55
|
-
subject.valid?.must_equal true
|
56
|
-
subject.errors.size.must_equal 0
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
49
|
|
63
50
|
describe "for invalid formats" do
|
64
51
|
it "rejects invalid formats" do
|
65
|
-
subject = build_phone_validation true
|
52
|
+
subject = build_phone_validation true
|
53
|
+
subject.phone = '999'
|
66
54
|
subject.valid?.must_equal false
|
67
55
|
subject.errors.size.must_equal 1
|
68
56
|
end
|
69
57
|
|
70
58
|
it "generates an error message of type invalid" do
|
71
|
-
subject = build_phone_validation true
|
59
|
+
subject = build_phone_validation true
|
60
|
+
subject.phone = '999'
|
72
61
|
subject.valid?.must_equal false
|
73
62
|
subject.errors[:phone].include?(subject.errors.generate_message(:phone, :invalid)).must_equal true
|
74
63
|
end
|
@@ -28,7 +28,7 @@ describe "Postal Code Validation" do
|
|
28
28
|
formats.each do |format|
|
29
29
|
it "should validate format of postal code with #{format}" do
|
30
30
|
subject = build_postal_code_record :country => country
|
31
|
-
subject.postal_code = format.gsub('
|
31
|
+
subject.postal_code = format.gsub(/[@#]/, '@' => 'A', '#' => '9')
|
32
32
|
subject.valid?.must_equal true
|
33
33
|
subject.errors.size.must_equal 0
|
34
34
|
end
|
@@ -7,6 +7,12 @@ describe "Url Validation" do
|
|
7
7
|
TestRecord.new
|
8
8
|
end
|
9
9
|
|
10
|
+
def build_ftp_record
|
11
|
+
TestRecord.reset_callbacks(:validate)
|
12
|
+
TestRecord.validates :url, :url => 'ftp'
|
13
|
+
TestRecord.new
|
14
|
+
end
|
15
|
+
|
10
16
|
describe "valid urls" do
|
11
17
|
it "accepts urls without port number" do
|
12
18
|
subject = build_url_record
|
@@ -28,12 +34,20 @@ describe "Url Validation" do
|
|
28
34
|
subject.valid?.must_equal true
|
29
35
|
subject.errors.size.must_equal 0
|
30
36
|
end
|
37
|
+
|
31
38
|
it "accepts valid SSL urls" do
|
32
39
|
subject = build_url_record
|
33
40
|
subject.url = 'https://www.verrot.fr'
|
34
41
|
subject.valid?.must_equal true
|
35
42
|
subject.errors.size.must_equal 0
|
36
43
|
end
|
44
|
+
|
45
|
+
it "accepts ftp if defined" do
|
46
|
+
subject = build_ftp_record
|
47
|
+
subject.url = 'ftp://ftp.verrot.fr'
|
48
|
+
subject.valid?.must_equal true
|
49
|
+
subject.errors.size.must_equal 0
|
50
|
+
end
|
37
51
|
end
|
38
52
|
|
39
53
|
describe "for invalid urls" do
|
@@ -50,5 +64,26 @@ describe "Url Validation" do
|
|
50
64
|
subject.valid?.must_equal false
|
51
65
|
subject.errors[:url].include?(subject.errors.generate_message(:url, :invalid)).must_equal true
|
52
66
|
end
|
67
|
+
|
68
|
+
it "rejects nil urls" do
|
69
|
+
subject = build_url_record
|
70
|
+
subject.url = nil
|
71
|
+
subject.valid?.must_equal false
|
72
|
+
subject.errors.size.must_equal 1
|
73
|
+
end
|
74
|
+
|
75
|
+
it "rejects empty urls" do
|
76
|
+
subject = build_url_record
|
77
|
+
subject.url = ''
|
78
|
+
subject.valid?.must_equal false
|
79
|
+
subject.errors.size.must_equal 1
|
80
|
+
end
|
81
|
+
|
82
|
+
it "rejects invalid protocols" do
|
83
|
+
subject = build_url_record
|
84
|
+
subject.url = 'ftp://ftp.verrot.fr'
|
85
|
+
subject.valid?.must_equal false
|
86
|
+
subject.errors.size.must_equal 1
|
87
|
+
end
|
53
88
|
end
|
54
89
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activevalidators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,11 +14,11 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2012-
|
17
|
+
date: 2012-07-06 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: bundler
|
21
|
-
requirement: &
|
21
|
+
requirement: &70278581021300 !ruby/object:Gem::Requirement
|
22
22
|
none: false
|
23
23
|
requirements:
|
24
24
|
- - ! '>='
|
@@ -26,10 +26,10 @@ dependencies:
|
|
26
26
|
version: '0'
|
27
27
|
type: :development
|
28
28
|
prerelease: false
|
29
|
-
version_requirements: *
|
29
|
+
version_requirements: *70278581021300
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: minitest
|
32
|
-
requirement: &
|
32
|
+
requirement: &70278581019760 !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
35
|
- - ! '>='
|
@@ -37,10 +37,10 @@ dependencies:
|
|
37
37
|
version: '0'
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
|
-
version_requirements: *
|
40
|
+
version_requirements: *70278581019760
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
|
-
requirement: &
|
43
|
+
requirement: &70278581018660 !ruby/object:Gem::Requirement
|
44
44
|
none: false
|
45
45
|
requirements:
|
46
46
|
- - ! '>='
|
@@ -48,10 +48,10 @@ dependencies:
|
|
48
48
|
version: 0.8.7
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
|
-
version_requirements: *
|
51
|
+
version_requirements: *70278581018660
|
52
52
|
- !ruby/object:Gem::Dependency
|
53
53
|
name: activemodel
|
54
|
-
requirement: &
|
54
|
+
requirement: &70278581017920 !ruby/object:Gem::Requirement
|
55
55
|
none: false
|
56
56
|
requirements:
|
57
57
|
- - ! '>='
|
@@ -59,10 +59,32 @@ dependencies:
|
|
59
59
|
version: 3.0.0
|
60
60
|
type: :runtime
|
61
61
|
prerelease: false
|
62
|
-
version_requirements: *
|
62
|
+
version_requirements: *70278581017920
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: phony
|
65
|
+
requirement: &70278581017380 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ~>
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.7.4
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: *70278581017380
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: countries
|
76
|
+
requirement: &70278581016540 !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 0.8.2
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: *70278581016540
|
63
85
|
- !ruby/object:Gem::Dependency
|
64
86
|
name: mail
|
65
|
-
requirement: &
|
87
|
+
requirement: &70278581010060 !ruby/object:Gem::Requirement
|
66
88
|
none: false
|
67
89
|
requirements:
|
68
90
|
- - ! '>='
|
@@ -70,10 +92,10 @@ dependencies:
|
|
70
92
|
version: '0'
|
71
93
|
type: :runtime
|
72
94
|
prerelease: false
|
73
|
-
version_requirements: *
|
95
|
+
version_requirements: *70278581010060
|
74
96
|
- !ruby/object:Gem::Dependency
|
75
97
|
name: date_validator
|
76
|
-
requirement: &
|
98
|
+
requirement: &70278581008820 !ruby/object:Gem::Requirement
|
77
99
|
none: false
|
78
100
|
requirements:
|
79
101
|
- - ! '>='
|
@@ -81,7 +103,7 @@ dependencies:
|
|
81
103
|
version: '0'
|
82
104
|
type: :runtime
|
83
105
|
prerelease: false
|
84
|
-
version_requirements: *
|
106
|
+
version_requirements: *70278581008820
|
85
107
|
description: ActiveValidators is a collection of ActiveModel/ActiveRecord validations
|
86
108
|
email:
|
87
109
|
- franck@verrot.fr
|
@@ -121,7 +143,7 @@ files:
|
|
121
143
|
- test/validations/tracking_number_test.rb
|
122
144
|
- test/validations/twitter_test.rb
|
123
145
|
- test/validations/url_test.rb
|
124
|
-
homepage: http://github.com/
|
146
|
+
homepage: http://github.com/franckverrot/activevalidators
|
125
147
|
licenses: []
|
126
148
|
post_install_message:
|
127
149
|
rdoc_options: []
|
@@ -132,7 +154,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
154
|
requirements:
|
133
155
|
- - ! '>='
|
134
156
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
157
|
+
version: 1.9.2
|
136
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
159
|
none: false
|
138
160
|
requirements:
|