active_storage_validations 0.8.0 → 0.8.1
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: 3f4d056a6bc935d7d423adedecf19fc841ba2d4711315eb4586cc54f39f0cc7a
|
4
|
+
data.tar.gz: a2474738de0db8878368672a4fdf393a06ab18f3db87a9a3ff320c4e7a0536ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 256142921c422090717ce89451700a9635a83ac69e52709ba07bf3a8acfa18a15a7e328a47e232e4aa0ff5237fabe7d0b5f73fe3a9e1bf13458fad665887cd9b
|
7
|
+
data.tar.gz: 550358993e4bfa899503821d3dcdbbf8c4daced1255f9daff4bbd2c603164f439228b230a4d3cd05155395325a838e2112dd7a956e9373bfb73e42219a5a761a
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ class User < ApplicationRecord
|
|
32
32
|
validates :photos, attached: true, content_type: ['image/png', 'image/jpg', 'image/jpeg'],
|
33
33
|
dimension: { width: { min: 800, max: 2400 },
|
34
34
|
height: { min: 600, max: 1800 }, message: 'is not given between dimension' }
|
35
|
-
validates :image, attached: true,
|
35
|
+
validates :image, attached: true,
|
36
36
|
content_type: ['image/png', 'image/jpg'],
|
37
37
|
aspect_ratio: :landscape
|
38
38
|
end
|
@@ -56,6 +56,18 @@ end
|
|
56
56
|
|
57
57
|
### More examples
|
58
58
|
|
59
|
+
- Content type validation using symbols. In order to infer the correct mime type from the symbol, the types must be registered with `Mime::Type`.
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
class User < ApplicationRecord
|
63
|
+
has_one_attached :avatar
|
64
|
+
has_many_attached :photos
|
65
|
+
|
66
|
+
validates :avatar, attached: true, content_type: :png # Mime[:png].to_s => 'image/png'
|
67
|
+
validates :photos, attached: true, content_type: [:png, :jpg, :jpeg]
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
59
71
|
- Dimension validation with `width`, `height` and `in`.
|
60
72
|
|
61
73
|
```ruby
|
@@ -68,7 +80,7 @@ class User < ApplicationRecord
|
|
68
80
|
end
|
69
81
|
```
|
70
82
|
|
71
|
-
- Dimension validation with `min` and `max` range for width and height
|
83
|
+
- Dimension validation with `min` and `max` range for width and height:
|
72
84
|
|
73
85
|
```ruby
|
74
86
|
class User < ApplicationRecord
|
@@ -84,6 +96,21 @@ class User < ApplicationRecord
|
|
84
96
|
end
|
85
97
|
```
|
86
98
|
|
99
|
+
- Aspect ration validation:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
class User < ApplicationRecord
|
103
|
+
has_one_attached :avatar
|
104
|
+
has_one_attached :photo
|
105
|
+
has_many_attached :photos
|
106
|
+
|
107
|
+
validates :avatar, aspect_ratio: :square
|
108
|
+
validates :photo, aspect_ratio: :landscape
|
109
|
+
|
110
|
+
# you can also pass dynamic aspect ratio, like :is_4_3, :is_16_9, etc
|
111
|
+
validates :photos, aspect_ratio: :is_4_3
|
112
|
+
end
|
113
|
+
|
87
114
|
## Internationalization (I18n)
|
88
115
|
|
89
116
|
Active Storage Validations use I18n for errors messages. For this add there keys in your translation file:
|
@@ -197,6 +224,14 @@ You are welcome to contribute.
|
|
197
224
|
- https://github.com/D-system
|
198
225
|
- https://github.com/ivanelrey
|
199
226
|
- https://github.com/phlegx
|
227
|
+
- https://github.com/rr-dev
|
228
|
+
- https://github.com/dsmalko
|
229
|
+
- https://github.com/danderozier
|
230
|
+
- https://github.com/cseelus
|
231
|
+
- https://github.com/vkinelev
|
232
|
+
- https://github.com/reed
|
233
|
+
- https://github.com/connorshea
|
234
|
+
- https://github.com/Atul9
|
200
235
|
|
201
236
|
## License
|
202
237
|
|
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.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
|
-
rubygems_version: 3.0.
|
140
|
+
rubygems_version: 3.0.4
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Validations for Active Storage
|