can_has_validations 1.9.0 → 1.11.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 +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +16 -11
- data/lib/can_has_validations/version.rb +1 -1
- data/test/dummy/config/application.rb +1 -1
- data/test/dummy/log/test.log +48 -0
- metadata +13 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 265cc0daee73649e7814d073dcb6243a700fc95d44465a3e65d8873c747d70fc
|
4
|
+
data.tar.gz: 38ed63f29a3801450380bb3024279ddfdcbd018a68bfca9a57fa3a7d057e7982
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00ddc79d0260617c6b4563bc80d0d3e9f3e265c1a635c91f0be6b785efd57ff453d76a9d0146d536771e8f7cd1e17d2d1a8d5716c6c5b8f3839f5669735f0c47
|
7
|
+
data.tar.gz: d7903a4fb900618b36020e56207391c6c88bb31d77d6fc524c003015852f17e8e6837561bf057eee73ed83a6e0e6f220f931dc2507fadea1cb793fed34095625
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -17,7 +17,7 @@ Validations provided:
|
|
17
17
|
* URL
|
18
18
|
* Write Once
|
19
19
|
|
20
|
-
All validators use the newer Rails
|
20
|
+
All validators use the newer Rails syntax:
|
21
21
|
|
22
22
|
validates :some_attribute, email: true
|
23
23
|
|
@@ -89,7 +89,7 @@ so this is useful with Mongoid as well.
|
|
89
89
|
|
90
90
|
## Grandparent validator ##
|
91
91
|
|
92
|
-
Ensures two (or more) associations share a common parent value.
|
92
|
+
Ensures two (or more) associations share a common parent value.
|
93
93
|
|
94
94
|
`allow_nil: true` will not only allow the attribute/association to be nil, but
|
95
95
|
also any of the `:scope` values.
|
@@ -100,21 +100,21 @@ Consider a model tree like this:
|
|
100
100
|
has_many :addresses
|
101
101
|
has_many :phones
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
class Address < ActiveRecord::Base
|
105
105
|
belongs_to :user
|
106
106
|
has_many :orders
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
class Phone < ActiveRecord::Base
|
110
110
|
belongs_to :user
|
111
111
|
has_many :orders
|
112
112
|
end
|
113
|
-
|
113
|
+
|
114
114
|
class Order < ActiveRecord::Base
|
115
115
|
belongs_to :address
|
116
116
|
belongs_to :phone
|
117
|
-
|
117
|
+
|
118
118
|
validates :phone, grandparent: {scope: :address, parent: :user}
|
119
119
|
end
|
120
120
|
|
@@ -123,10 +123,10 @@ For any `Order`, this ensures that both `:address` and `:phone` belong to the sa
|
|
123
123
|
|
124
124
|
Basically it starts with the attribute being validated (`:phone` in this case)
|
125
125
|
and the scoped attributes (just `:address` in this case, but you can supply an
|
126
|
-
array if needed, eg: `scope: [:billing_address, :mailing_address]` ).
|
126
|
+
array if needed, eg: `scope: [:billing_address, :mailing_address]` ).
|
127
127
|
|
128
128
|
Then, it looks for the attribute that is the common parent (`:user` in the above
|
129
|
-
example). So, it's looking for `phone.user` and `address.user`.
|
129
|
+
example). So, it's looking for `phone.user` and `address.user`.
|
130
130
|
|
131
131
|
Finally, it's comparing those values to make sure they match. In this case, if
|
132
132
|
`phone.user` and `address.user` match, then the validation passes. If the phone and
|
@@ -245,7 +245,7 @@ Always skips over nil values; use `:presence` to validate those.
|
|
245
245
|
# These two are the same, except `:now` produces a clearer error message:
|
246
246
|
validates :finish_at, after: :now
|
247
247
|
validates :finish_at, after: ->(r){ Time.now }
|
248
|
-
|
248
|
+
|
249
249
|
# Long versions, if you need to add extra validation options:
|
250
250
|
validates :start_at, before: {value_of: :finish_at, message: "..." }
|
251
251
|
validates :finish_at, after: {values_of: [:start_at, :alt_start_at], if: ... }
|
@@ -315,6 +315,11 @@ Default messages are as follows:
|
|
315
315
|
after: "must be after %{attribute2}"
|
316
316
|
|
317
317
|
|
318
|
-
##
|
318
|
+
## Contributing
|
319
|
+
|
320
|
+
PRs are welcomed.
|
321
|
+
|
322
|
+
|
323
|
+
## License
|
319
324
|
|
320
|
-
|
325
|
+
MIT
|
@@ -10,7 +10,7 @@ require "can_has_validations"
|
|
10
10
|
module Dummy
|
11
11
|
class Application < Rails::Application
|
12
12
|
# Initialize configuration defaults for originally generated Rails version.
|
13
|
-
config.load_defaults
|
13
|
+
config.load_defaults Rails::VERSION::STRING.to_f
|
14
14
|
|
15
15
|
# Configuration for the application, engines, and railties goes here.
|
16
16
|
#
|
data/test/dummy/log/test.log
CHANGED
@@ -63,3 +63,51 @@ CanHasValidationsTest: test_truth
|
|
63
63
|
CanHasValidationsTest: test_truth
|
64
64
|
---------------------------------
|
65
65
|
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
66
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
67
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
68
|
+
---------------------------------
|
69
|
+
CanHasValidationsTest: test_truth
|
70
|
+
---------------------------------
|
71
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
72
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
73
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
74
|
+
---------------------------------
|
75
|
+
CanHasValidationsTest: test_truth
|
76
|
+
---------------------------------
|
77
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
78
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
79
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
80
|
+
---------------------------------
|
81
|
+
CanHasValidationsTest: test_truth
|
82
|
+
---------------------------------
|
83
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
84
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
85
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
86
|
+
---------------------------------
|
87
|
+
CanHasValidationsTest: test_truth
|
88
|
+
---------------------------------
|
89
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
90
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
91
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mBEGIN deferred TRANSACTION[0m
|
92
|
+
---------------------------------
|
93
|
+
CanHasValidationsTest: test_truth
|
94
|
+
---------------------------------
|
95
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mROLLBACK TRANSACTION[0m
|
96
|
+
[1m[36mActiveRecord::SchemaMigration Load (1.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
97
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mBEGIN deferred TRANSACTION[0m
|
98
|
+
---------------------------------
|
99
|
+
CanHasValidationsTest: test_truth
|
100
|
+
---------------------------------
|
101
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[31mROLLBACK TRANSACTION[0m
|
102
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.9ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
103
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mBEGIN deferred TRANSACTION[0m
|
104
|
+
---------------------------------
|
105
|
+
CanHasValidationsTest: test_truth
|
106
|
+
---------------------------------
|
107
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mROLLBACK TRANSACTION[0m
|
108
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.9ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mBEGIN deferred TRANSACTION[0m
|
110
|
+
---------------------------------
|
111
|
+
CanHasValidationsTest: test_truth
|
112
|
+
---------------------------------
|
113
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mROLLBACK TRANSACTION[0m
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: can_has_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thomas morgan
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rails
|
@@ -16,20 +15,14 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '7.2'
|
18
|
+
version: '7.0'
|
23
19
|
type: :runtime
|
24
20
|
prerelease: false
|
25
21
|
version_requirements: !ruby/object:Gem::Requirement
|
26
22
|
requirements:
|
27
23
|
- - ">="
|
28
24
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '7.2'
|
25
|
+
version: '7.0'
|
33
26
|
- !ruby/object:Gem::Dependency
|
34
27
|
name: rake
|
35
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -48,17 +41,17 @@ dependencies:
|
|
48
41
|
name: sqlite3
|
49
42
|
requirement: !ruby/object:Gem::Requirement
|
50
43
|
requirements:
|
51
|
-
- - "
|
44
|
+
- - ">="
|
52
45
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
46
|
+
version: '0'
|
54
47
|
type: :development
|
55
48
|
prerelease: false
|
56
49
|
version_requirements: !ruby/object:Gem::Requirement
|
57
50
|
requirements:
|
58
|
-
- - "
|
51
|
+
- - ">="
|
59
52
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
61
|
-
description: 'Assorted Rails
|
53
|
+
version: '0'
|
54
|
+
description: 'Assorted Rails 7.x-8.x validators: Array, Email, Existence, Grandparent,
|
62
55
|
Hash keys, Hash values, Hostname, IP address, Ordering, URL, Write Once'
|
63
56
|
email:
|
64
57
|
- tm@iprog.com
|
@@ -132,7 +125,6 @@ homepage: https://github.com/zarqman/can_has_validations
|
|
132
125
|
licenses:
|
133
126
|
- MIT
|
134
127
|
metadata: {}
|
135
|
-
post_install_message:
|
136
128
|
rdoc_options: []
|
137
129
|
require_paths:
|
138
130
|
- lib
|
@@ -140,17 +132,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
132
|
requirements:
|
141
133
|
- - ">="
|
142
134
|
- !ruby/object:Gem::Version
|
143
|
-
version: '
|
135
|
+
version: '2.7'
|
144
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
137
|
requirements:
|
146
138
|
- - ">="
|
147
139
|
- !ruby/object:Gem::Version
|
148
140
|
version: '0'
|
149
141
|
requirements: []
|
150
|
-
rubygems_version: 3.
|
151
|
-
signing_key:
|
142
|
+
rubygems_version: 3.6.9
|
152
143
|
specification_version: 4
|
153
|
-
summary: Assorted Rails
|
144
|
+
summary: Assorted Rails 7.x-8.x validators
|
154
145
|
test_files:
|
155
146
|
- test/can_has_validations_test.rb
|
156
147
|
- test/dummy/README.rdoc
|
@@ -163,6 +154,7 @@ test_files:
|
|
163
154
|
- test/dummy/bin/rails
|
164
155
|
- test/dummy/bin/rake
|
165
156
|
- test/dummy/bin/setup
|
157
|
+
- test/dummy/config.ru
|
166
158
|
- test/dummy/config/application.rb
|
167
159
|
- test/dummy/config/boot.rb
|
168
160
|
- test/dummy/config/cable.yml
|
@@ -183,7 +175,6 @@ test_files:
|
|
183
175
|
- test/dummy/config/locales/en.yml
|
184
176
|
- test/dummy/config/routes.rb
|
185
177
|
- test/dummy/config/storage.yml
|
186
|
-
- test/dummy/config.ru
|
187
178
|
- test/dummy/db/test.sqlite3
|
188
179
|
- test/dummy/log/test.log
|
189
180
|
- test/dummy/public/404.html
|