active_storage_validations 1.1.2 → 1.1.3
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: 1ee85f42558858c115d91d107a0b67f6088d65b4cbc1ec8461f4f5baf230a025
|
4
|
+
data.tar.gz: 4cf3fdb1bde0e805d22ad7d7d81d43cf5b378e06bde5443d938d1e390deee816
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c3a532221860176a87f042126b7a068425d2efca7ec908393691ae807af36e55b10d38180f8226dd73c1da0cff9f7dc5d1408ac1049ccbef58033ce9fdca48c
|
7
|
+
data.tar.gz: 469f3406a95dc8d0466d475d1cabc5b5658e813430728593140ce78b96892d0837da075f83d2901967b258f7ff57cf830390401737cb2f739b0bcd6c13d16aa3
|
data/README.md
CHANGED
@@ -350,21 +350,21 @@ end
|
|
350
350
|
|
351
351
|
To run tests in root folder of gem:
|
352
352
|
|
353
|
-
* `BUNDLE_GEMFILE=gemfiles/rails_6_0.gemfile bundle exec rake test` to run for Rails 6.0
|
354
353
|
* `BUNDLE_GEMFILE=gemfiles/rails_6_1.gemfile bundle exec rake test` to run for Rails 6.1
|
355
354
|
* `BUNDLE_GEMFILE=gemfiles/rails_7_0.gemfile bundle exec rake test` to run for Rails 7.0
|
355
|
+
* `BUNDLE_GEMFILE=gemfiles/rails_7_1.gemfile bundle exec rake test` to run for Rails 7.0
|
356
356
|
* `BUNDLE_GEMFILE=gemfiles/rails_next.gemfile bundle exec rake test` to run for Rails main branch
|
357
357
|
|
358
358
|
Snippet to run in console:
|
359
359
|
|
360
|
-
```
|
361
|
-
BUNDLE_GEMFILE=gemfiles/rails_6_0.gemfile bundle
|
360
|
+
```bash
|
362
361
|
BUNDLE_GEMFILE=gemfiles/rails_6_1.gemfile bundle
|
363
362
|
BUNDLE_GEMFILE=gemfiles/rails_7_0.gemfile bundle
|
363
|
+
BUNDLE_GEMFILE=gemfiles/rails_7_1.gemfile bundle
|
364
364
|
BUNDLE_GEMFILE=gemfiles/rails_next.gemfile bundle
|
365
|
-
BUNDLE_GEMFILE=gemfiles/rails_6_0.gemfile bundle exec rake test
|
366
365
|
BUNDLE_GEMFILE=gemfiles/rails_6_1.gemfile bundle exec rake test
|
367
366
|
BUNDLE_GEMFILE=gemfiles/rails_7_0.gemfile bundle exec rake test
|
367
|
+
BUNDLE_GEMFILE=gemfiles/rails_7_1.gemfile bundle exec rake test
|
368
368
|
BUNDLE_GEMFILE=gemfiles/rails_next.gemfile bundle exec rake test
|
369
369
|
```
|
370
370
|
|
@@ -453,6 +453,7 @@ You are welcome to contribute.
|
|
453
453
|
- https://github.com/Fonsan
|
454
454
|
- https://github.com/tagliala
|
455
455
|
- https://github.com/ocarreterom
|
456
|
+
- https://github.com/aditya-cherukuri
|
456
457
|
|
457
458
|
|
458
459
|
## License
|
@@ -1,46 +1,53 @@
|
|
1
|
-
module Validatable
|
2
|
-
extend ActiveSupport::Concern
|
3
1
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
2
|
+
require "active_support/concern"
|
3
|
+
|
4
|
+
module ActiveStorageValidations
|
5
|
+
module Matchers
|
6
|
+
module Validatable
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def validate
|
12
|
+
@subject.validate
|
13
|
+
end
|
14
|
+
|
15
|
+
def validator_errors_for_attribute
|
16
|
+
@subject.errors.details[@attribute_name].select do |error|
|
17
|
+
error[:validator_type] == validator_class.to_sym
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def is_valid?
|
22
|
+
validator_errors_for_attribute.none? do |error|
|
23
|
+
error[:error].in?(available_errors)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def available_errors
|
28
|
+
[
|
29
|
+
*validator_class::ERROR_TYPES,
|
30
|
+
*error_from_custom_message
|
31
|
+
].compact
|
32
|
+
end
|
33
|
+
|
34
|
+
def validator_class
|
35
|
+
self.class.name.gsub(/::Matchers|Matcher/, '').constantize
|
36
|
+
end
|
37
|
+
|
38
|
+
def error_from_custom_message
|
39
|
+
associated_validation = @subject.class.validators_on(@attribute_name).find do |validator|
|
40
|
+
validator.class == validator_class
|
41
|
+
end
|
42
|
+
|
43
|
+
associated_validation.options[:message]
|
44
|
+
end
|
45
|
+
|
46
|
+
def has_an_error_message_which_is_custom_message?
|
47
|
+
validator_errors_for_attribute.one? do |error|
|
48
|
+
error[:error] == @custom_message
|
49
|
+
end
|
50
|
+
end
|
44
51
|
end
|
45
52
|
end
|
46
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_storage_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|