active_storage_validations 0.9.2 → 0.9.3

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: 6e8b30d036f53b6e00b209c9fe9a34339ff23aa35b789da9585df7fee6c8dfad
4
- data.tar.gz: 0655072452aa29e24bcea5abb01e6b72bf6ddee6f2646d92eb8b13dbaeff128f
3
+ metadata.gz: d75309ae07f32e9107683721c2a700dea9a435cdc5801c8488a0bf2df18e6162
4
+ data.tar.gz: 3f14dc96d9d8fff1fb309460c896d631db5777d663b6d7b00f47d08b5e8dc034
5
5
  SHA512:
6
- metadata.gz: 8df0893d2048e22d55660f590a747d55b2fff2595bae0f7da8b9151079d2c87e7d09a5e3059529a9fd9ef1231e44b4e9c610d3d22c9da5bfc8e49eb3aa0d25ca
7
- data.tar.gz: a55c3ba3ff97b5478061fc8a8307127231dbbbb64f49fdcaccea85e6c896e48e777b30e09c97d44b9d84d61b8b5c4ef6abdb843171120b1ae739b38ebf916fb2
6
+ metadata.gz: a04233bd7b37c89c45fa9d7fe3ef32be5b50ed40181a2b29fa8711049958d8b2bcacceb7f8e4aa7fd7c9714fb506387c7f26050eeecb623f0ceb3d361b501cf7
7
+ data.tar.gz: 0e43d6b501c8c8d45f1c99110d7504a8ca124353dbe26819f6c9febe34f1c4710c842f5c42945584a7e64bac10ad1efcc18a97afa5ea4987e04024b2f6cdf8d4
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Active Storage Validations
2
2
 
3
+ ![MiniTest](https://github.com/igorkasyanchuk/active_storage_validations/workflows/MiniTest/badge.svg)
4
+ [![RailsJazz](https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/my_other.svg?raw=true)](https://www.railsjazz.com)
5
+ [![https://www.patreon.com/igorkasyanchuk](https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/patron.svg?raw=true)](https://www.patreon.com/igorkasyanchuk)
6
+
3
7
  If you are using `active_storage` gem and you want to add simple validations for it, like presence or content_type you need to write a custom validation method.
4
8
 
5
9
  This gems doing it for you. Just use `attached: true` or `content_type: 'image/png'` validation.
@@ -332,7 +336,13 @@ You are welcome to contribute.
332
336
  - https://github.com/molfar
333
337
  - https://github.com/connorshea
334
338
  - https://github.com/yshmarov
339
+ - https://github.com/fongfan999
340
+ - https://github.com/cooperka
341
+ - https://github.com/dolarsrg
335
342
 
336
343
  ## License
337
344
 
338
345
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
346
+
347
+ [<img src="https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/more_gems.png?raw=true"
348
+ />](https://www.railsjazz.com/)
@@ -15,3 +15,8 @@ de:
15
15
  dimension_height_less_than_or_equal_to: "Höhe muss kleiner oder gleich %{length} Pixel sein"
16
16
  dimension_width_equal_to: "Bildbreite muss genau %{length} Pixel sein"
17
17
  dimension_height_equal_to: "Bildhöhe muss genau %{length} Pixel sein"
18
+ aspect_ratio_not_square: "muss quadratisch sein"
19
+ aspect_ratio_not_portrait: "muss Hochformat sein"
20
+ aspect_ratio_not_landscape: "muss Querformat sein"
21
+ aspect_ratio_is_not: "muss ein Bildseitenverhältnis von %{aspect_ratio} haben"
22
+ aspect_ratio_unknown: "hat ein unbekanntes Bildseitenverhältnis"
@@ -16,7 +16,7 @@ es:
16
16
  dimension_width_equal_to: "el ancho debe ser igual a %{length} pixel"
17
17
  dimension_height_equal_to: "la altura debe ser igual a %{length} pixel"
18
18
  aspect_ratio_not_square: "debe ser una imagen cuadrada"
19
- aspect_ratio_not_portrait: "debe ser una imagen de retrato"
20
- aspect_ratio_not_landscape: "debe ser una imagen de paisaje"
19
+ aspect_ratio_not_portrait: "debe ser una imagen vertical"
20
+ aspect_ratio_not_landscape: "debe ser una imagen apaisada"
21
21
  aspect_ratio_is_not: "debe tener una relación de aspecto de %{aspect_ratio}"
22
22
  aspect_ratio_unknown: "tiene una relación de aspecto desconocida"
@@ -0,0 +1,22 @@
1
+ it:
2
+ errors:
3
+ messages:
4
+ content_type_invalid: "ha un tipo di contenuto non valido"
5
+ file_size_out_of_range: "la dimensione del file %{file_size} non è compresa nell’intervallo consentito"
6
+ limit_out_of_range: "il valore è al di fuori dell’intervallo consentito"
7
+ image_metadata_missing: "non è un'immagine valida"
8
+ dimension_min_inclusion: "deve essere maggiore o uguale a %{width} x %{height} pixel"
9
+ dimension_max_inclusion: "deve essere minore o uguale a %{width} x %{height} pixel"
10
+ dimension_width_inclusion: "la larghezza deve essere compresa tra %{min} e %{max} pixel"
11
+ dimension_height_inclusion: "l’altezza deve essere compresa tra %{min} e %{max} pixel"
12
+ dimension_width_greater_than_or_equal_to: "la larghezza deve essere maggiore o uguale a %{length} pixel"
13
+ dimension_height_greater_than_or_equal_to: "l’altezza deve essere maggiore o uguale a %{length} pixel"
14
+ dimension_width_less_than_or_equal_to: "la larghezza deve essere minore o uguale a %{length} pixel"
15
+ dimension_height_less_than_or_equal_to: "l’altezza deve essere minore o uguale a %{length} pixel"
16
+ dimension_width_equal_to: "la larghezza deve essere pari a %{length} pixel"
17
+ dimension_height_equal_to: "l’altezza deve essere pari a %{length} pixel"
18
+ aspect_ratio_not_square: "deve essere un’immagine quadrata"
19
+ aspect_ratio_not_portrait: "l’orientamento dell’immagine deve essere verticale"
20
+ aspect_ratio_not_landscape: "l’orientamento dell’immagine deve essere orizzontale"
21
+ aspect_ratio_is_not: "deve avere un rapporto altezza / larghezza di %{aspect_ratio}"
22
+ aspect_ratio_unknown: "ha un rapporto altezza / larghezza sconosciuto"
@@ -0,0 +1,22 @@
1
+ pl:
2
+ errors:
3
+ messages:
4
+ content_type_invalid: "jest nieprawidłowego typu"
5
+ file_size_out_of_range: "rozmiar %{file_size} nie zawiera się w dopuszczalnym zakresie"
6
+ limit_out_of_range: "ilość przekracza dopuszczalny zakres"
7
+ image_metadata_missing: "nie jest prawidłowym obrazem"
8
+ dimension_min_inclusion: "musi być równe lub większe od %{width} x %{height} pixeli"
9
+ dimension_max_inclusion: "musi być równe lub mniejsze od %{width} x %{height} pixeli"
10
+ dimension_width_inclusion: "szerokość musi wynosić od %{min} do %{max} pixeli"
11
+ dimension_height_inclusion: "wysokość musi wynosić od %{min} do %{max} pixeli"
12
+ dimension_width_greater_than_or_equal_to: "szerokość musi mieć co najmniej %{length} pixeli"
13
+ dimension_height_greater_than_or_equal_to: "wysokość musi mieć co najmniej %{length} pixeli"
14
+ dimension_width_less_than_or_equal_to: "szerokość musi mieć co najwyżej %{length} pixeli"
15
+ dimension_height_less_than_or_equal_to: "wysokość musi mieć co najwyżej %{length} pixeli"
16
+ dimension_width_equal_to: "szerokość musi wynosić %{length} pixeli"
17
+ dimension_height_equal_to: "wysokość musi wynosić %{length} pixeli"
18
+ aspect_ratio_not_square: "musi mieć proporcje kwadratu"
19
+ aspect_ratio_not_portrait: "musi mieć proporcje portretu"
20
+ aspect_ratio_not_landscape: "musi mieć proporcje pejzażu"
21
+ aspect_ratio_is_not: "musi mieć proporcje %{aspect_ratio}"
22
+ aspect_ratio_unknown: "ma nieokreślone proporcje"
@@ -0,0 +1,22 @@
1
+ vi:
2
+ errors:
3
+ messages:
4
+ content_type_invalid: "tệp không hợp lệ"
5
+ file_size_out_of_range: "kích thước %{file_size} vượt giới hạn"
6
+ limit_out_of_range: "tổng số tệp vượt giới hạn"
7
+ image_metadata_missing: "không phải là ảnh"
8
+ dimension_min_inclusion: "phải lớn hơn hoặc bằng %{width} x %{height} pixel"
9
+ dimension_max_inclusion: "phải nhỏ hơn hoặc bằng %{width} x %{height} pixel"
10
+ dimension_width_inclusion: "chiều rộng không nằm trong %{min} và %{max} pixel"
11
+ dimension_height_inclusion: "chiều cao không nằm trong %{min} và %{max} pixel"
12
+ dimension_width_greater_than_or_equal_to: "chiều rộng phải lớn hơn hoặc bằng %{length} pixel"
13
+ dimension_height_greater_than_or_equal_to: "chiều cao phải lớn hơn hoặc bằng %{length} pixel"
14
+ dimension_width_less_than_or_equal_to: "chiều rộng phải nhỏ hơn hoặc bằng %{length} pixel"
15
+ dimension_height_less_than_or_equal_to: "chiều cao phải nhỏ hơn hoặc bằng %{length} pixel"
16
+ dimension_width_equal_to: "chiều rộng phải bằng %{length} pixel"
17
+ dimension_height_equal_to: "chiều cao phải bằng %{length} pixel"
18
+ aspect_ratio_not_square: "phải là ảnh hình vuông"
19
+ aspect_ratio_not_portrait: "phải là ảnh đứng"
20
+ aspect_ratio_not_landscape: "phải là ảnh ngang"
21
+ aspect_ratio_is_not: "phải có tỉ lệ ảnh %{aspect_ratio}"
22
+ aspect_ratio_unknown: "tỉ lệ ảnh không xác định"
@@ -36,10 +36,9 @@ module ActiveStorageValidations
36
36
  end
37
37
 
38
38
  def is_valid?(file)
39
- if options[:with].is_a?(Regexp)
40
- options[:with].match?(content_type(file).to_s)
41
- else
42
- content_type(file).in?(types)
39
+ file_type = content_type(file)
40
+ types.any? do |type|
41
+ type == file_type || (type.is_a?(Regexp) && type.match?(file_type.to_s))
43
42
  end
44
43
  end
45
44
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveStorageValidations
4
- VERSION = '0.9.2'
4
+ VERSION = '0.9.3'
5
5
  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.2
4
+ version: 0.9.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: 2021-01-12 00:00:00.000000000 Z
11
+ date: 2021-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -108,12 +108,15 @@ files:
108
108
  - config/locales/en.yml
109
109
  - config/locales/es.yml
110
110
  - config/locales/fr.yml
111
+ - config/locales/it.yml
111
112
  - config/locales/ja.yml
112
113
  - config/locales/nl.yml
114
+ - config/locales/pl.yml
113
115
  - config/locales/pt-BR.yml
114
116
  - config/locales/ru.yml
115
117
  - config/locales/tr.yml
116
118
  - config/locales/uk.yml
119
+ - config/locales/vi.yml
117
120
  - lib/active_storage_validations.rb
118
121
  - lib/active_storage_validations/aspect_ratio_validator.rb
119
122
  - lib/active_storage_validations/attached_validator.rb
@@ -150,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
153
  - !ruby/object:Gem::Version
151
154
  version: '0'
152
155
  requirements: []
153
- rubygems_version: 3.0.3
156
+ rubygems_version: 3.1.4
154
157
  signing_key:
155
158
  specification_version: 4
156
159
  summary: Validations for Active Storage