servactory 2.6.1 → 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64f8eb059214e69b961c2e6a5c91565eff6372eaa64677a5d7da42f8f301d38b
4
- data.tar.gz: c49125a5572e80d044668bcd70b6f45bd9d4c0c0109fe6ce35238fc1b630d405
3
+ metadata.gz: c2a39700d311e8928abfbebb095ba075230533aef2939fd9668b8d649a257a00
4
+ data.tar.gz: 4da3314f25f0f24f499c3cc9d1a6ad08dfd516b747d2df1379513894fb0fad58
5
5
  SHA512:
6
- metadata.gz: 9c17c8c39353bca7c6efc198472c7c8e088a934ea1e9181522d653580ec3dad9f9046169b38396d1b2508860fe21b3fc1fef1eb0d6d84b7e913b50e78664a8ff
7
- data.tar.gz: a3555354a011e24848d9cbace96d5dad5db690d9a07b8cb41318b7e5820e24f04194f55b7faee4e38c8f7a521e13a2022f756802ce49c4168211135263980ba6
6
+ metadata.gz: 9f1946fa5be2ad7762cdf751e0167f58c42f45ec2fe04943c21691e614d7b2680224d008dba256878809fe348aaeea93392f9eaf3594a7a4451753be97758079
7
+ data.tar.gz: 03d1c3295c54b92515b08073bba127fe5bb71529e174204b043ef428b8fd6bb1e673fc94f4f400059a50e17b845d06572601da8d137bbd570cf1a50cb07668e3
@@ -66,10 +66,10 @@ module Servactory
66
66
  ########################################################################
67
67
 
68
68
  def message_for_input_with(service:, input:, value:, option_value:, reason:, **)
69
- i18n_key = "servactory.inputs.validations.must.dynamic_options.consists_of"
69
+ i18n_key = "inputs.validations.must.dynamic_options.consists_of"
70
70
  i18n_key += reason.present? ? ".#{reason}" : ".default"
71
71
 
72
- I18n.t(
72
+ service.translate(
73
73
  i18n_key,
74
74
  service_class_name: service.class_name,
75
75
  input_name: input.name,
@@ -79,10 +79,10 @@ module Servactory
79
79
  end
80
80
 
81
81
  def message_for_internal_with(service:, internal:, value:, option_value:, reason:, **)
82
- i18n_key = "servactory.internals.validations.must.dynamic_options.consists_of"
82
+ i18n_key = "internals.validations.must.dynamic_options.consists_of"
83
83
  i18n_key += reason.present? ? ".#{reason}" : ".default"
84
84
 
85
- I18n.t(
85
+ service.translate(
86
86
  i18n_key,
87
87
  service_class_name: service.class_name,
88
88
  internal_name: internal.name,
@@ -92,10 +92,10 @@ module Servactory
92
92
  end
93
93
 
94
94
  def message_for_output_with(service:, output:, value:, option_value:, reason:, **)
95
- i18n_key = "servactory.outputs.validations.must.dynamic_options.consists_of"
95
+ i18n_key = "outputs.validations.must.dynamic_options.consists_of"
96
96
  i18n_key += reason.present? ? ".#{reason}" : ".default"
97
97
 
98
- I18n.t(
98
+ service.translate(
99
99
  i18n_key,
100
100
  service_class_name: service.class_name,
101
101
  output_name: output.name,
@@ -82,11 +82,25 @@ module Servactory
82
82
  common_condition_with(...)
83
83
  end
84
84
 
85
- def common_condition_with(value:, option:, **)
85
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
86
+ def common_condition_with(value:, option:, input: nil, internal: nil, output: nil)
86
87
  option_value = option.value&.to_sym
87
88
 
88
89
  return [false, :unknown] unless @formats.key?(option_value)
89
90
 
91
+ attribute = Utils.define_attribute_with(input: input, internal: internal, output: output)
92
+
93
+ if value.blank? &&
94
+ (
95
+ (attribute.input? && attribute.optional?) ||
96
+ (
97
+ (attribute.internal? || attribute.output?) &&
98
+ attribute.types.include?(NilClass)
99
+ )
100
+ )
101
+ return true
102
+ end
103
+
90
104
  format_options = @formats.fetch(option_value)
91
105
 
92
106
  format_pattern = option.properties.fetch(:pattern, format_options.fetch(:pattern))
@@ -95,6 +109,7 @@ module Servactory
95
109
 
96
110
  option.properties.fetch(:validator, format_options.fetch(:validator)).call(value: value)
97
111
  end
112
+ # rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
98
113
 
99
114
  ########################################################################
100
115
 
@@ -4,7 +4,7 @@ module Servactory
4
4
  module VERSION
5
5
  MAJOR = 2
6
6
  MINOR = 6
7
- PATCH = 1
7
+ PATCH = 3
8
8
  PRE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.1
4
+ version: 2.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-15 00:00:00.000000000 Z
11
+ date: 2024-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -366,7 +366,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
366
366
  - !ruby/object:Gem::Version
367
367
  version: '0'
368
368
  requirements: []
369
- rubygems_version: 3.5.6
369
+ rubygems_version: 3.5.11
370
370
  signing_key:
371
371
  specification_version: 4
372
372
  summary: A set of tools for building reliable services of any complexity