active_storage_validations 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -5
- data/lib/active_storage_validations/dimension_validator.rb +4 -4
- data/lib/active_storage_validations/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e8b30d036f53b6e00b209c9fe9a34339ff23aa35b789da9585df7fee6c8dfad
|
4
|
+
data.tar.gz: 0655072452aa29e24bcea5abb01e6b72bf6ddee6f2646d92eb8b13dbaeff128f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8df0893d2048e22d55660f590a747d55b2fff2595bae0f7da8b9151079d2c87e7d09a5e3059529a9fd9ef1231e44b4e9c610d3d22c9da5bfc8e49eb3aa0d25ca
|
7
|
+
data.tar.gz: a55c3ba3ff97b5478061fc8a8307127231dbbbb64f49fdcaccea85e6c896e48e777b30e09c97d44b9d84d61b8b5c4ef6abdb843171120b1ae739b38ebf916fb2
|
data/README.md
CHANGED
@@ -4,8 +4,6 @@ If you are using `active_storage` gem and you want to add simple validations for
|
|
4
4
|
|
5
5
|
This gems doing it for you. Just use `attached: true` or `content_type: 'image/png'` validation.
|
6
6
|
|
7
|
-
[![Build Status](https://travis-ci.org/igorkasyanchuk/active_storage_validations.svg?branch=master)](https://travis-ci.org/igorkasyanchuk/active_storage_validations)
|
8
|
-
|
9
7
|
## What it can do
|
10
8
|
|
11
9
|
* validates if file(s) attached
|
@@ -287,9 +285,7 @@ To run tests in root folder of gem:
|
|
287
285
|
|
288
286
|
* `BUNDLE_GEMFILE=gemfiles/rails_5_2.gemfile bundle exec rake test` to run for Rails 5.2
|
289
287
|
* `BUNDLE_GEMFILE=gemfiles/rails_6_0.gemfile bundle exec rake test` to run for Rails 6.0
|
290
|
-
* `BUNDLE_GEMFILE=gemfiles/rails_6_1.gemfile bundle exec rake test` to run for Rails 6.1
|
291
|
-
|
292
|
-
To play with app `cd test/dummy` and `rails s -b 0.0.0.0` (before `rails db:migrate`).
|
288
|
+
* `BUNDLE_GEMFILE=gemfiles/rails_6_1.gemfile bundle exec rake test` to run for Rails 6.1
|
293
289
|
|
294
290
|
## Known issues
|
295
291
|
|
@@ -52,7 +52,7 @@ module ActiveStorageValidations
|
|
52
52
|
# Rails 5
|
53
53
|
def validate_each(record, attribute, _value)
|
54
54
|
return true unless record.send(attribute).attached?
|
55
|
-
|
55
|
+
|
56
56
|
files = Array.wrap(record.send(attribute))
|
57
57
|
files.each do |file|
|
58
58
|
# Analyze file first if not analyzed to get all required metadata.
|
@@ -110,7 +110,7 @@ module ActiveStorageValidations
|
|
110
110
|
else
|
111
111
|
if file_metadata[length] != options[length]
|
112
112
|
add_error(record, attribute, options[:message].presence || :"dimension_#{length}_equal_to", length: options[length])
|
113
|
-
return false
|
113
|
+
return false
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
@@ -119,10 +119,10 @@ module ActiveStorageValidations
|
|
119
119
|
true # valid file
|
120
120
|
end
|
121
121
|
|
122
|
-
def add_error(record, attribute, type,
|
122
|
+
def add_error(record, attribute, type, **attrs)
|
123
123
|
key = options[:message].presence || type
|
124
124
|
return if record.errors.added?(attribute, key)
|
125
|
-
record.errors.add(attribute, key,
|
125
|
+
record.errors.add(attribute, key, **attrs)
|
126
126
|
end
|
127
127
|
|
128
128
|
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: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 5.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: combustion
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: mini_magick
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|