can_has_validations 1.11.1 → 1.12.0
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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 13e394fba7dc57b9c99ee269fe7c1bbb868e3f5622ed98a2b142a5ffc7ca4fec
|
|
4
|
+
data.tar.gz: bf2d29c9de0698c7cc9bc734534e556f7b6625f61ba032cef15ccb71f4e7ac70
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 64c45df4c4266413b999c21aff1356ddfb2178e7dc54e115638f9b08c6a50c2f12c237a2573ecd4684665b3b7690cd408cc4b5b8f58ba34dd74f5a8e520b6436
|
|
7
|
+
data.tar.gz: b6b3ec67d6711a4e8a6fabcf1ee018bf58f003fc29f0500e5bec21d85e34d9104ec5ccc2dfe46f4f4a287d986cb0f44872bcf0ed5e3dbe14f55c521ef283c5d6
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
# validates :database, url: {port: [5432, nil]}
|
|
8
8
|
# to allow scheme's default port, must specify `nil` too
|
|
9
9
|
# :scheme defaults to `%w(http https)`
|
|
10
|
+
# to allow any, use `scheme: nil`
|
|
11
|
+
# to require blank, use `scheme: [nil]`
|
|
12
|
+
# note: to allow no scheme, uri must still start with '//'
|
|
10
13
|
# :host defaults to `nil` which allows any
|
|
11
14
|
# :port defaults to `nil` which allows any
|
|
12
15
|
# to require blank, use `port: false` or `port: [nil]`
|
|
@@ -26,6 +29,8 @@ module ActiveModel::Validations
|
|
|
26
29
|
options[:scheme].call(record)
|
|
27
30
|
elsif options[:scheme].is_a?(Symbol)
|
|
28
31
|
record.send(options[:scheme])
|
|
32
|
+
elsif options.key?(:scheme) && options[:scheme].nil?
|
|
33
|
+
[u&.scheme]
|
|
29
34
|
else
|
|
30
35
|
Array.wrap(options[:scheme] || %w(http https))
|
|
31
36
|
end
|
|
@@ -54,7 +59,7 @@ module ActiveModel::Validations
|
|
|
54
59
|
Array.wrap(options[:port])
|
|
55
60
|
end
|
|
56
61
|
|
|
57
|
-
if !u || !u2 ||
|
|
62
|
+
if !u || !u2 || allowed_schemes.exclude?(u.scheme) || allowed_hosts.exclude?(u.host) || allowed_ports.exclude?(u.port)
|
|
58
63
|
record.errors.add(attribute, :invalid_url, **options.merge(value: value, scheme: allowed_schemes, host: allowed_hosts, port: allowed_ports))
|
|
59
64
|
end
|
|
60
65
|
end
|
data/test/dummy/log/test.log
CHANGED
|
@@ -118,3 +118,10 @@ Generating image variants require the image_processing gem. Please add `gem "ima
|
|
|
118
118
|
CanHasValidationsTest: test_truth
|
|
119
119
|
---------------------------------
|
|
120
120
|
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mROLLBACK TRANSACTION[0m
|
|
121
|
+
Generating image variants require the image_processing gem. Please add `gem "image_processing", "~> 1.2"` to your Gemfile or set `config.active_storage.variant_processor = :disabled`.
|
|
122
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
|
123
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mBEGIN deferred TRANSACTION[0m
|
|
124
|
+
---------------------------------
|
|
125
|
+
CanHasValidationsTest: test_truth
|
|
126
|
+
---------------------------------
|
|
127
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mROLLBACK TRANSACTION[0m
|