validators 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -9
- data/bin/sync-disposable-hostnames +6 -6
- data/bin/sync-tld +4 -4
- data/data/disposable.json +8272 -2
- data/data/tld.json +0 -1
- data/lib/validators/constants.rb +1 -0
- data/lib/validators/hostname.rb +1 -1
- data/lib/validators/validates_cnpj_format_of.rb +2 -1
- data/lib/validators/validates_cpf_format_of.rb +2 -1
- data/lib/validators/validates_datetime.rb +29 -18
- data/lib/validators/validates_email_format_of.rb +19 -13
- data/lib/validators/validates_ip_address.rb +13 -9
- data/lib/validators/validates_ownership_of.rb +11 -9
- data/lib/validators/validates_ssh_private_key.rb +15 -7
- data/lib/validators/validates_ssh_public_key.rb +5 -2
- data/lib/validators/validates_url_format_of.rb +5 -3
- data/lib/validators/version.rb +2 -2
- data/test/schema.rb +1 -1
- data/test/support/emails.rb +37 -27
- data/test/support/models.rb +1 -1
- data/test/support/urls.rb +28 -28
- data/test/validators/validates_datetime/after_option_test.rb +5 -5
- data/test/validators/validates_datetime/before_option_test.rb +2 -2
- data/test/validators/validates_datetime/defaults_test.rb +1 -1
- data/test/validators/validates_email_format_of_test.rb +11 -11
- data/test/validators/validates_ip_address/ipv4_test.rb +2 -2
- data/test/validators/validates_ip_address/ipv6_test.rb +2 -2
- data/test/validators/validates_ip_address_test.rb +2 -2
- data/test/validators/validates_ownership_of_test.rb +5 -5
- data/test/validators/validates_ssh_private_key/dsa_test.rb +2 -2
- data/test/validators/validates_ssh_private_key/rsa_test.rb +1 -1
- data/test/validators/validates_url_format_of/with_tld_validation_test.rb +1 -1
- data/test/validators/validates_url_format_of/without_tld_validation_test.rb +7 -7
- data/validators.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca3a7326669a28e5030b94ee05a28319992344298c08db969acec22218ef9dcb
|
4
|
+
data.tar.gz: 1507f0cce162f06a5a2d07cfe8b38f8ae2e562b309ce06818af142f1eb544f71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 959bfdeb54af37788694558d2132cce3b76a3ee6ef7998856c36fa989efc06c1a1615e3e5faef6aaba2df7af29bc00245dcb6f170bb4afb988b0c8f66d275baf
|
7
|
+
data.tar.gz: a2f238aa20d5f37ec90e54545035919913cdb673b4e207bf389ea9f529762cf050af1f711f772a370858f71f70b823a2bc7a7ee4f73735989db8b174554c9280
|
data/README.md
CHANGED
@@ -67,7 +67,7 @@ class Task < ActiveRecord::Base
|
|
67
67
|
belongs_to :user
|
68
68
|
belongs_to :category
|
69
69
|
|
70
|
-
validates_ownership_of :category, :
|
70
|
+
validates_ownership_of :category, with: :user
|
71
71
|
end
|
72
72
|
|
73
73
|
user = User.find(1)
|
@@ -76,11 +76,11 @@ another_user = User.find(2)
|
|
76
76
|
user_category = user.categories.first
|
77
77
|
another_user_category = another_user.categories.first
|
78
78
|
|
79
|
-
task = user.tasks.create(:
|
79
|
+
task = user.tasks.create(category: user_category)
|
80
80
|
task.valid?
|
81
81
|
#=> true
|
82
82
|
|
83
|
-
task = user.tasks.create(:
|
83
|
+
task = user.tasks.create(category: another_user_category)
|
84
84
|
task.valid?
|
85
85
|
#=> false
|
86
86
|
```
|
@@ -90,8 +90,8 @@ task.valid?
|
|
90
90
|
```ruby
|
91
91
|
class Server < ActiveRecord::Base
|
92
92
|
validates_ip_address :address
|
93
|
-
validates_ip_address :address, :
|
94
|
-
validates_ip_address :address, :
|
93
|
+
validates_ip_address :address, only: :v4
|
94
|
+
validates_ip_address :address, only: :v6
|
95
95
|
end
|
96
96
|
```
|
97
97
|
|
@@ -100,11 +100,11 @@ end
|
|
100
100
|
```ruby
|
101
101
|
class Server < ActiveRecord::Base
|
102
102
|
validates_datetime :starts_at
|
103
|
-
validates_datetime :ends_at, :
|
104
|
-
validates_datetime :ends_at, :
|
105
|
-
validates_datetime :ends_at, :
|
103
|
+
validates_datetime :ends_at, after: :starts_at, if: :starts_at?
|
104
|
+
validates_datetime :ends_at, after: :now
|
105
|
+
validates_datetime :ends_at, before: :today
|
106
106
|
|
107
|
-
validates :starts_at, :
|
107
|
+
validates :starts_at, datetime: true
|
108
108
|
end
|
109
109
|
```
|
110
110
|
|
@@ -1,16 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "open-uri"
|
4
|
+
require "json"
|
5
5
|
|
6
|
-
domains = JSON.load(open(
|
7
|
-
domains += JSON.load(open(
|
8
|
-
domains += JSON.load(open(
|
6
|
+
domains = JSON.load(open("https://raw.githubusercontent.com/ivolo/disposable-email-domains/master/index.json").read)
|
7
|
+
domains += JSON.load(open("https://raw.githubusercontent.com/andreis/disposable-email-domains/master/domains.json").read)
|
8
|
+
domains += JSON.load(open("https://raw.githubusercontent.com/FGRibreau/mailchecker/master/list.json").read).flatten
|
9
9
|
|
10
10
|
domains.map!(&:downcase)
|
11
11
|
domains.uniq!
|
12
12
|
domains.sort!
|
13
13
|
|
14
|
-
File.open(
|
14
|
+
File.open("./data/disposable.json", "w") do |file|
|
15
15
|
file << JSON.pretty_generate(domains)
|
16
16
|
end
|
data/bin/sync-tld
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "open-uri"
|
4
|
+
require "json"
|
5
5
|
|
6
|
-
tlds = open(
|
6
|
+
tlds = open("https://data.iana.org/TLD/tlds-alpha-by-domain.txt").read.lines
|
7
7
|
tlds.shift # remove update notice
|
8
8
|
|
9
9
|
tlds.map!(&:downcase)
|
@@ -11,6 +11,6 @@ tlds.map!(&:strip)
|
|
11
11
|
tlds.sort!
|
12
12
|
tlds.uniq!
|
13
13
|
|
14
|
-
File.open(
|
14
|
+
File.open("./data/tld.json", "w") do |file|
|
15
15
|
file << JSON.pretty_generate(tlds)
|
16
16
|
end
|