active_storage_validations 1.1.2 → 1.1.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: 288f21f798861bd7e44ad225052620bfcfd2d58efe73f0aeda8f4964ace98f56
4
- data.tar.gz: b19cce430aae6c1eed3c2d29cbafa6d07b36423f122157603d4391a892267d64
3
+ metadata.gz: 1ee85f42558858c115d91d107a0b67f6088d65b4cbc1ec8461f4f5baf230a025
4
+ data.tar.gz: 4cf3fdb1bde0e805d22ad7d7d81d43cf5b378e06bde5443d938d1e390deee816
5
5
  SHA512:
6
- metadata.gz: e7d6e8ac601a1bd25c2c4f4a199782e7b8dd5821ce99a2bcf14a60c0d8dd2f5e55c46d1eeae758438f8e9da34ae2f9366bf4690345dde242af897cf405dc1624
7
- data.tar.gz: a4335b501b1298517053f45ec6f1192d053cd73fd682bc19127f5891aa7704e2116659991e29c3d2c4bd6ff9acf0847b91389b6bbfafb52d2c45a941dbb9dd35
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
- private
5
-
6
- def validate
7
- @subject.validate
8
- end
9
-
10
- def validator_errors_for_attribute
11
- @subject.errors.details[@attribute_name].select do |error|
12
- error[:validator_type] == validator_class.to_sym
13
- end
14
- end
15
-
16
- def is_valid?
17
- validator_errors_for_attribute.none? do |error|
18
- error[:error].in?(available_errors)
19
- end
20
- end
21
-
22
- def available_errors
23
- [
24
- *validator_class::ERROR_TYPES,
25
- *error_from_custom_message
26
- ].compact
27
- end
28
-
29
- def validator_class
30
- self.class.name.gsub(/::Matchers|Matcher/, '').constantize
31
- end
32
-
33
- def error_from_custom_message
34
- associated_validation = @subject.class.validators_on(@attribute_name).find do |validator|
35
- validator.class == validator_class
36
- end
37
-
38
- associated_validation.options[:message]
39
- end
40
-
41
- def has_an_error_message_which_is_custom_message?
42
- validator_errors_for_attribute.one? do |error|
43
- error[:error] == @custom_message
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveStorageValidations
4
- VERSION = '1.1.2'
4
+ VERSION = '1.1.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: 1.1.2
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-14 00:00:00.000000000 Z
11
+ date: 2023-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob