database_validations 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/database_validations/validations/belongs_to_handlers.rb +3 -3
- data/lib/database_validations/validations/belongs_to_options.rb +2 -2
- data/lib/database_validations/validations/uniqueness_handlers.rb +1 -1
- data/lib/database_validations/validations/valid_without_database_validations.rb +1 -1
- data/lib/database_validations/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef7ec227437ca99440f72837a6dfe1d3fa21416ade5bcf60b2e3780037fae6af
|
4
|
+
data.tar.gz: 6e8a592f0884396b80b33d001c9194d9d97c1e78c14b099d66c140dee266edd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 642ee70b3bdb810e06adeb4ebcf0e285ba5487a76ee5a8990cec6656e0f90ee3f27f8daf02402664addeaafabf592b0b8d68a339ab21dcda052b6d6b82fb2d81
|
7
|
+
data.tar.gz: f34ade4123b89869f946da93c334e713e575eeb6b2b6908faefe38007f6c241854a512222e3f64caba2ae945c8001b5e22dd65d7ebe385fbfe738e2e2d85ff14
|
@@ -7,7 +7,7 @@ module DatabaseValidations
|
|
7
7
|
|
8
8
|
validate do
|
9
9
|
Helpers.each_belongs_to_presence_validator(self.class) do |validator|
|
10
|
-
next unless validator.
|
10
|
+
next unless validator.column_and_relation_blank_for?(self)
|
11
11
|
|
12
12
|
errors.add(validator.relation, :blank, message: :required)
|
13
13
|
end
|
@@ -18,7 +18,7 @@ module DatabaseValidations
|
|
18
18
|
output = super(context)
|
19
19
|
|
20
20
|
Helpers.each_belongs_to_presence_validator(self.class) do |validator|
|
21
|
-
next if validator.
|
21
|
+
next if validator.column_and_relation_blank_for?(self)
|
22
22
|
|
23
23
|
validates_with(ActiveRecord::Validations::PresenceValidator, validator.validates_presence_options)
|
24
24
|
end
|
@@ -43,7 +43,7 @@ module DatabaseValidations
|
|
43
43
|
private
|
44
44
|
|
45
45
|
def perform_validations(options = {})
|
46
|
-
options[:validate] == false || valid_without_database_validations(options[:context])
|
46
|
+
options[:validate] == false || valid_without_database_validations?(options[:context])
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -17,8 +17,8 @@ module DatabaseValidations
|
|
17
17
|
end
|
18
18
|
|
19
19
|
# @return [Boolean]
|
20
|
-
def
|
21
|
-
instance.public_send(column).
|
20
|
+
def column_and_relation_blank_for?(instance)
|
21
|
+
instance.public_send(column).blank? && instance.public_send(relation).blank?
|
22
22
|
end
|
23
23
|
|
24
24
|
def handle_foreign_key_error(instance)
|
@@ -35,7 +35,7 @@ module DatabaseValidations
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def perform_validations(options = {})
|
38
|
-
options[:validate] == false || valid_without_database_validations(options[:context])
|
38
|
+
options[:validate] == false || valid_without_database_validations?(options[:context])
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeniy Demin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|