can_has_validations 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92f14adff8817a7d4d4d6d5b9a1b00a0860f9279ca86dafaad567e67e4970ee6
|
4
|
+
data.tar.gz: ea792545cf1ed844ec5ad498068dd9990712b240c31f3e214d6c3518f429f9b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2b1cb68de2eeb27e3d1a7b0c8b86d9d64f76f62a7f51feddfc5e62c9f009f14caadf7fd6eafac768c47e77fb31ed27cc8edab196b5d565d626582e0025403db
|
7
|
+
data.tar.gz: a7a1fa2e08fe737f88b9e428047d01b398a852a82528439483abfb1251027d0e5542429b82c981f8dc3cf5ece39aca0e3404e009bc5d8b75a15850bf33585dd7
|
@@ -12,14 +12,20 @@ module ActiveModel::Validations
|
|
12
12
|
# nil to be allowed. prevent this.
|
13
13
|
def validate(record)
|
14
14
|
attributes.each do |attribute|
|
15
|
-
|
16
|
-
validate_each(record, attribute, value)
|
15
|
+
validate_each(record, attribute, nil)
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
20
|
-
def validate_each(record, attribute,
|
21
|
-
|
22
|
-
|
19
|
+
def validate_each(record, attribute, _)
|
20
|
+
return unless record.persisted?
|
21
|
+
if !record.respond_to?("#{attribute}_changed?") && record.respond_to?("#{attribute}_id_changed?")
|
22
|
+
attr2 = "#{attribute}_id"
|
23
|
+
else
|
24
|
+
attr2 = attribute
|
25
|
+
end
|
26
|
+
if record.send("#{attr2}_changed?")
|
27
|
+
if options[:immutable_nil] || !record.send("#{attr2}_was").nil?
|
28
|
+
value = record.read_attribute_for_validation(attribute)
|
23
29
|
record.errors.add(attribute, :unchangeable, options.except(:immutable_nil).merge!(value: value))
|
24
30
|
end
|
25
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thomas morgan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '5.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '6.
|
22
|
+
version: '6.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '5.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '6.
|
32
|
+
version: '6.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: sqlite3
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,7 +99,8 @@ files:
|
|
99
99
|
- test/dummy/script/rails
|
100
100
|
- test/test_helper.rb
|
101
101
|
homepage: https://github.com/zarqman/can_has_validations
|
102
|
-
licenses:
|
102
|
+
licenses:
|
103
|
+
- MIT
|
103
104
|
metadata: {}
|
104
105
|
post_install_message:
|
105
106
|
rdoc_options: []
|
@@ -116,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
117
|
- !ruby/object:Gem::Version
|
117
118
|
version: '0'
|
118
119
|
requirements: []
|
119
|
-
rubygems_version: 3.0.
|
120
|
+
rubygems_version: 3.0.9
|
120
121
|
signing_key:
|
121
122
|
specification_version: 4
|
122
123
|
summary: Assorted Rails 5.x-6.x validators
|