active_storage_validations 1.1.2 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +86 -59
- data/lib/active_storage_validations/aspect_ratio_validator.rb +47 -22
- data/lib/active_storage_validations/attached_validator.rb +12 -3
- data/lib/active_storage_validations/concerns/errorable.rb +38 -0
- data/lib/active_storage_validations/concerns/symbolizable.rb +8 -6
- data/lib/active_storage_validations/content_type_validator.rb +41 -6
- data/lib/active_storage_validations/dimension_validator.rb +15 -15
- data/lib/active_storage_validations/limit_validator.rb +44 -7
- data/lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb +128 -0
- data/lib/active_storage_validations/matchers/attached_validator_matcher.rb +20 -23
- data/lib/active_storage_validations/matchers/concerns/active_storageable.rb +17 -0
- data/lib/active_storage_validations/matchers/concerns/allow_blankable.rb +26 -0
- data/lib/active_storage_validations/matchers/concerns/contextable.rb +35 -0
- data/lib/active_storage_validations/matchers/concerns/messageable.rb +26 -0
- data/lib/active_storage_validations/matchers/concerns/rspecable.rb +25 -0
- data/lib/active_storage_validations/matchers/concerns/validatable.rb +45 -43
- data/lib/active_storage_validations/matchers/content_type_validator_matcher.rb +39 -25
- data/lib/active_storage_validations/matchers/dimension_validator_matcher.rb +61 -44
- data/lib/active_storage_validations/matchers/size_validator_matcher.rb +41 -24
- data/lib/active_storage_validations/matchers.rb +1 -0
- data/lib/active_storage_validations/metadata.rb +42 -28
- data/lib/active_storage_validations/processable_image_validator.rb +14 -5
- data/lib/active_storage_validations/size_validator.rb +7 -6
- data/lib/active_storage_validations/version.rb +1 -1
- data/lib/active_storage_validations.rb +1 -1
- metadata +9 -3
- data/lib/active_storage_validations/error_handler.rb +0 -21
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.4
|
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
|
+
date: 2023-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -234,14 +234,20 @@ files:
|
|
234
234
|
- lib/active_storage_validations.rb
|
235
235
|
- lib/active_storage_validations/aspect_ratio_validator.rb
|
236
236
|
- lib/active_storage_validations/attached_validator.rb
|
237
|
+
- lib/active_storage_validations/concerns/errorable.rb
|
237
238
|
- lib/active_storage_validations/concerns/symbolizable.rb
|
238
239
|
- lib/active_storage_validations/content_type_validator.rb
|
239
240
|
- lib/active_storage_validations/dimension_validator.rb
|
240
241
|
- lib/active_storage_validations/engine.rb
|
241
|
-
- lib/active_storage_validations/error_handler.rb
|
242
242
|
- lib/active_storage_validations/limit_validator.rb
|
243
243
|
- lib/active_storage_validations/matchers.rb
|
244
|
+
- lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb
|
244
245
|
- lib/active_storage_validations/matchers/attached_validator_matcher.rb
|
246
|
+
- lib/active_storage_validations/matchers/concerns/active_storageable.rb
|
247
|
+
- lib/active_storage_validations/matchers/concerns/allow_blankable.rb
|
248
|
+
- lib/active_storage_validations/matchers/concerns/contextable.rb
|
249
|
+
- lib/active_storage_validations/matchers/concerns/messageable.rb
|
250
|
+
- lib/active_storage_validations/matchers/concerns/rspecable.rb
|
245
251
|
- lib/active_storage_validations/matchers/concerns/validatable.rb
|
246
252
|
- lib/active_storage_validations/matchers/content_type_validator_matcher.rb
|
247
253
|
- lib/active_storage_validations/matchers/dimension_validator_matcher.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module ActiveStorageValidations
|
2
|
-
module ErrorHandler
|
3
|
-
|
4
|
-
def initialize_error_options(options)
|
5
|
-
{
|
6
|
-
validator_type: self.class.to_sym,
|
7
|
-
custom_message: (options[:message] if options[:message].present?)
|
8
|
-
}.compact
|
9
|
-
end
|
10
|
-
|
11
|
-
def add_error(record, attribute, error_type, **errors_options)
|
12
|
-
type = errors_options[:custom_message].presence || error_type
|
13
|
-
return if record.errors.added?(attribute, type)
|
14
|
-
|
15
|
-
# You can read https://api.rubyonrails.org/classes/ActiveModel/Errors.html#method-i-add
|
16
|
-
# to better understand how Rails model errors work
|
17
|
-
record.errors.add(attribute, type, **errors_options)
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|