validators 2.7.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -9
  3. data/bin/sync-disposable-hostnames +6 -6
  4. data/bin/sync-tld +4 -4
  5. data/data/disposable.json +8272 -2
  6. data/data/tld.json +0 -1
  7. data/lib/validators/constants.rb +1 -0
  8. data/lib/validators/hostname.rb +1 -1
  9. data/lib/validators/validates_cnpj_format_of.rb +2 -1
  10. data/lib/validators/validates_cpf_format_of.rb +2 -1
  11. data/lib/validators/validates_datetime.rb +29 -18
  12. data/lib/validators/validates_email_format_of.rb +19 -13
  13. data/lib/validators/validates_ip_address.rb +13 -9
  14. data/lib/validators/validates_ownership_of.rb +11 -9
  15. data/lib/validators/validates_ssh_private_key.rb +15 -7
  16. data/lib/validators/validates_ssh_public_key.rb +5 -2
  17. data/lib/validators/validates_url_format_of.rb +5 -3
  18. data/lib/validators/version.rb +2 -2
  19. data/test/schema.rb +1 -1
  20. data/test/support/emails.rb +37 -27
  21. data/test/support/models.rb +1 -1
  22. data/test/support/urls.rb +28 -28
  23. data/test/validators/validates_datetime/after_option_test.rb +5 -5
  24. data/test/validators/validates_datetime/before_option_test.rb +2 -2
  25. data/test/validators/validates_datetime/defaults_test.rb +1 -1
  26. data/test/validators/validates_email_format_of_test.rb +11 -11
  27. data/test/validators/validates_ip_address/ipv4_test.rb +2 -2
  28. data/test/validators/validates_ip_address/ipv6_test.rb +2 -2
  29. data/test/validators/validates_ip_address_test.rb +2 -2
  30. data/test/validators/validates_ownership_of_test.rb +5 -5
  31. data/test/validators/validates_ssh_private_key/dsa_test.rb +2 -2
  32. data/test/validators/validates_ssh_private_key/rsa_test.rb +1 -1
  33. data/test/validators/validates_url_format_of/with_tld_validation_test.rb +1 -1
  34. data/test/validators/validates_url_format_of/without_tld_validation_test.rb +7 -7
  35. data/validators.gemspec +2 -2
  36. metadata +4 -4
@@ -9,62 +9,62 @@ class ValidatesEmailFormatOfTest < Minitest::Test
9
9
 
10
10
  VALID_EMAILS.each do |email|
11
11
  test "accepts #{email.inspect} as a valid email" do
12
- user = User.new(:email => email, :corporate_email => email)
12
+ user = User.new(email: email, corporate_email: email)
13
13
  assert user.valid?
14
14
 
15
- user = Person.new(:email => email)
15
+ user = Person.new(email: email)
16
16
  assert user.valid?
17
17
  end
18
18
  end
19
19
 
20
20
  INVALID_EMAILS.each do |email|
21
21
  test "rejects #{email.inspect} as a valid email" do
22
- user = User.new(:email => email, :corporate_email => "invalid")
22
+ user = User.new(email: email, corporate_email: "invalid")
23
23
  refute user.valid?
24
24
 
25
- user = Person.new(:email => email)
25
+ user = Person.new(email: email)
26
26
  refute user.valid?
27
27
  end
28
28
  end
29
29
 
30
30
  test "uses default error message" do
31
- user = User.new(:email => "invalid")
31
+ user = User.new(email: "invalid")
32
32
 
33
33
  refute user.valid?
34
34
  assert_includes user.errors[:email], "is not a valid address"
35
35
  end
36
36
 
37
37
  test "rejects nil value" do
38
- user = User.new(:email => nil)
38
+ user = User.new(email: nil)
39
39
 
40
40
  refute user.valid?
41
41
  refute user.errors[:email].empty?
42
42
  end
43
43
 
44
44
  test "rejects empty value" do
45
- user = User.new(:email => "")
45
+ user = User.new(email: "")
46
46
 
47
47
  refute user.valid?
48
48
  refute user.errors[:email].empty?
49
49
  end
50
50
 
51
51
  test "validates multiple attributes" do
52
- user = User.new(:corporate_email => "invalid")
52
+ user = User.new(corporate_email: "invalid")
53
53
 
54
54
  refute user.valid?
55
55
  assert_includes user.errors[:corporate_email], "is not a valid address"
56
56
  end
57
57
 
58
58
  test "uses custom error message as :message options" do
59
- buyer = Buyer.new(:email => "invalid")
59
+ buyer = Buyer.new(email: "invalid")
60
60
 
61
61
  refute buyer.valid?
62
62
  assert_includes buyer.errors[:email], "is not a valid e-mail"
63
63
  end
64
64
 
65
65
  test "uses I18n string as error message [pt-BR]" do
66
- I18n.locale = :'pt-BR'
67
- user = User.new(:email => "invalid")
66
+ I18n.locale = :"pt-BR"
67
+ user = User.new(email: "invalid")
68
68
 
69
69
  refute user.valid?
70
70
  assert_includes user.errors[:email], "não parece ser um e-mail válido"
@@ -4,14 +4,14 @@ class Ipv4Test < Minitest::Test
4
4
  let(:user) { User.new }
5
5
 
6
6
  test "is valid" do
7
- User.validates_ip_address :url, :only => :v4
7
+ User.validates_ip_address :url, only: :v4
8
8
  user.url = "192.168.1.2"
9
9
 
10
10
  assert user.valid?
11
11
  end
12
12
 
13
13
  test "is invalid" do
14
- User.validates_ip_address :url, :only => :v4
14
+ User.validates_ip_address :url, only: :v4
15
15
  user.url = "FE80:0000:0000:0000:0202:B3FF:FE1E:8329"
16
16
 
17
17
  refute user.valid?
@@ -4,14 +4,14 @@ class Ipv6Test < Minitest::Test
4
4
  let(:user) { User.new }
5
5
 
6
6
  test "is valid" do
7
- User.validates_ip_address :url, :only => :v6
7
+ User.validates_ip_address :url, only: :v6
8
8
  user.url = "FE80:0000:0000:0000:0202:B3FF:FE1E:8329"
9
9
 
10
10
  assert user.valid?
11
11
  end
12
12
 
13
13
  test "is invalid" do
14
- User.validates_ip_address :url, :only => :v6
14
+ User.validates_ip_address :url, only: :v6
15
15
  user.url = "192.168.1.2"
16
16
 
17
17
  refute user.valid?
@@ -18,14 +18,14 @@ class ValidatesIpAddressTest < Minitest::Test
18
18
  end
19
19
 
20
20
  test "allows blank values" do
21
- User.validates_ip_address :url, :allow_blank => true
21
+ User.validates_ip_address :url, allow_blank: true
22
22
  user.url = ""
23
23
 
24
24
  assert user.valid?
25
25
  end
26
26
 
27
27
  test "allows nil values" do
28
- User.validates_ip_address :url, :allow_nil => true
28
+ User.validates_ip_address :url, allow_nil: true
29
29
  user.url = nil
30
30
 
31
31
  assert user.valid?
@@ -3,9 +3,9 @@ require "test_helper"
3
3
  class ValidatesOwnershipOfTest < Minitest::Test
4
4
  let(:user) { User.create! }
5
5
  let(:another_user) { User.create! }
6
- let(:category) { Category.create!(:user => user) }
7
- let(:another_category) { Category.create!(:user => another_user) }
8
- let(:task) { Task.new(:user => user, :category => category) }
6
+ let(:category) { Category.create!(user: user) }
7
+ let(:another_category) { Category.create!(user: another_user) }
8
+ let(:task) { Task.new(user: user, category: category) }
9
9
 
10
10
  setup do
11
11
  user
@@ -14,7 +14,7 @@ class ValidatesOwnershipOfTest < Minitest::Test
14
14
  another_category
15
15
  task
16
16
 
17
- Task.validates_ownership_of :category, :with => :user
17
+ Task.validates_ownership_of :category, with: :user
18
18
  end
19
19
 
20
20
  test "is valid when record is owned by the correct user" do
@@ -31,7 +31,7 @@ class ValidatesOwnershipOfTest < Minitest::Test
31
31
  end
32
32
 
33
33
  test "raises error when :with options is not a valid type" do
34
- assert_raises(ArgumentError) { Task.validates_ownership_of :category, :with => user }
34
+ assert_raises(ArgumentError) { Task.validates_ownership_of :category, with: user }
35
35
  end
36
36
 
37
37
  test "is invalid when owner is not present" do
@@ -19,7 +19,7 @@ class DsaTest < Minitest::Test
19
19
  end
20
20
 
21
21
  test "rejects rsa key" do
22
- record = model.new(key: SSHKey.generate(type: 'rsa').private_key)
22
+ record = model.new(key: SSHKey.generate(type: "rsa").private_key)
23
23
  record.valid?
24
24
 
25
25
  refute record.errors[:key].empty?
@@ -28,7 +28,7 @@ class DsaTest < Minitest::Test
28
28
  test "sets translated error message" do
29
29
  I18n.locale = "pt-BR"
30
30
 
31
- record = model.new(key: SSHKey.generate(type: 'rsa').private_key)
31
+ record = model.new(key: SSHKey.generate(type: "rsa").private_key)
32
32
  record.valid?
33
33
 
34
34
  assert_includes record.errors[:key], "precisa ser uma chave DSA"
@@ -7,7 +7,7 @@ class RsaTest < Minitest::Test
7
7
  end
8
8
 
9
9
  include ActiveModel::Model
10
- validates_ssh_private_key :key, type: 'rsa'
10
+ validates_ssh_private_key :key, type: "rsa"
11
11
  attr_accessor :key
12
12
  } }
13
13
 
@@ -2,7 +2,7 @@ require "test_helper"
2
2
 
3
3
  class ValidatesurlFormatUrlWithTldValidationTest < Minitest::Test
4
4
  test "rejects invalid TLD" do
5
- user = UserWithTLD.new('http://example.xy')
5
+ user = UserWithTLD.new("http://example.xy")
6
6
  refute user.valid?
7
7
  end
8
8
 
@@ -2,19 +2,19 @@ require "test_helper"
2
2
 
3
3
  class ValidatesurlFormatUrlWithoutTldValidationTest < Minitest::Test
4
4
  setup do
5
- User.validates_url_format_of :url, :allow_blank => false
5
+ User.validates_url_format_of :url, allow_blank: false
6
6
  end
7
7
 
8
8
  VALID_URLS.each do |url|
9
9
  test "accepts #{url.inspect} as a valid url" do
10
- user = User.new(:url => url)
10
+ user = User.new(url: url)
11
11
  assert user.valid?
12
12
  end
13
13
  end
14
14
 
15
15
  INVALID_URLS.each do |url|
16
16
  test "rejects #{url.inspect} as a valid url" do
17
- user = User.new(:url => url)
17
+ user = User.new(url: url)
18
18
  refute user.valid?
19
19
  end
20
20
  end
@@ -24,14 +24,14 @@ class ValidatesurlFormatUrlWithoutTldValidationTest < Minitest::Test
24
24
  end
25
25
 
26
26
  test "uses default error message" do
27
- user = User.new(:url => "invalid")
27
+ user = User.new(url: "invalid")
28
28
  refute user.valid?
29
29
  assert_includes user.errors[:url], "is not a valid address"
30
30
  end
31
31
 
32
32
  test "uses I18n string as error message [pt-BR]" do
33
- I18n.locale = :'pt-BR'
34
- user = User.new(:url => "invalid")
33
+ I18n.locale = :"pt-BR"
34
+ user = User.new(url: "invalid")
35
35
  refute user.valid?
36
36
  assert_includes user.errors[:url], "não parece ser uma URL válida"
37
37
  end
@@ -42,7 +42,7 @@ class ValidatesurlFormatUrlWithoutTldValidationTest < Minitest::Test
42
42
  end
43
43
 
44
44
  test "rejects blank urls" do
45
- user = User.new(url: '')
45
+ user = User.new(url: "")
46
46
  refute user.valid?
47
47
  end
48
48
  end
data/validators.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "http://rubygems.org/gems/validators"
11
11
  s.summary = "Add some nice ActiveModel/ActiveRecord validators."
12
12
  s.description = s.summary
13
- s.license = 'MIT'
13
+ s.license = "MIT"
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.add_development_dependency "activerecord"
21
21
  s.add_development_dependency "minitest-utils"
22
- s.add_development_dependency "sqlite3-ruby"
22
+ s.add_development_dependency "sqlite3"
23
23
  s.add_development_dependency "rake"
24
24
  s.add_development_dependency "pry-meta"
25
25
  s.add_development_dependency "cpf_cnpj"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validators
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-03 00:00:00.000000000 Z
11
+ date: 2018-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: sqlite3-ruby
42
+ name: sqlite3
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  version: '0'
209
209
  requirements: []
210
210
  rubyforge_project:
211
- rubygems_version: 2.7.3
211
+ rubygems_version: 2.7.6
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: Add some nice ActiveModel/ActiveRecord validators.