servactory 2.6.3 → 2.7.0
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 +4 -4
- data/config/locales/en.yml +12 -0
- data/config/locales/ru.yml +12 -0
- data/lib/servactory/actions/dsl.rb +2 -2
- data/lib/servactory/actions/tools/runner.rb +1 -1
- data/lib/servactory/configuration/setup.rb +3 -3
- data/lib/servactory/context/callable.rb +7 -7
- data/lib/servactory/context/workspace/inputs.rb +2 -2
- data/lib/servactory/context/workspace/internals.rb +3 -3
- data/lib/servactory/context/workspace/outputs.rb +3 -3
- data/lib/servactory/context/workspace.rb +19 -19
- data/lib/servactory/info/dsl.rb +3 -3
- data/lib/servactory/inputs/input.rb +5 -5
- data/lib/servactory/inputs/tools/validation.rb +7 -7
- data/lib/servactory/inputs/validations/required.rb +1 -1
- data/lib/servactory/internals/internal.rb +5 -5
- data/lib/servactory/maintenance/attributes/option.rb +13 -13
- data/lib/servactory/maintenance/attributes/tools/validation.rb +5 -5
- data/lib/servactory/maintenance/attributes/translator/inclusion.rb +2 -2
- data/lib/servactory/maintenance/attributes/translator/must.rb +8 -8
- data/lib/servactory/maintenance/attributes/translator/type.rb +12 -12
- data/lib/servactory/maintenance/attributes/validations/inclusion.rb +1 -1
- data/lib/servactory/maintenance/attributes/validations/must.rb +7 -7
- data/lib/servactory/maintenance/attributes/validations/type.rb +1 -1
- data/lib/servactory/maintenance/validations/object_schema.rb +11 -11
- data/lib/servactory/outputs/output.rb +5 -5
- data/lib/servactory/result.rb +4 -4
- data/lib/servactory/test_kit/result.rb +2 -2
- data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/valid_with_matcher.rb +1 -1
- data/lib/servactory/tool_kit/dynamic_options/consists_of.rb +14 -13
- data/lib/servactory/tool_kit/dynamic_options/format.rb +11 -8
- data/lib/servactory/tool_kit/dynamic_options/max.rb +12 -9
- data/lib/servactory/tool_kit/dynamic_options/min.rb +12 -9
- data/lib/servactory/tool_kit/dynamic_options/multiple_of.rb +103 -0
- data/lib/servactory/tool_kit/dynamic_options/must.rb +16 -13
- data/lib/servactory/version.rb +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0392bf65a7bdc8c133d517c581655e2a29ce4665d8a2c9dcde7eec7e1a6d1cc
|
4
|
+
data.tar.gz: 5f57c9201660ae628fb471f1bef146acb2face2aad22f10b02a0a1e2b1f9fd55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6741ccebe3ddb1f8a7b6c2908a92b5b6a3f4af00d188c5e1d2f54f663d5758ebc3956c5a0ca2efa97fed0fe97187e594557083a0cd6ca2372487430c6ca005e
|
7
|
+
data.tar.gz: e2374b66d0d8b6b3c49b07f66bc7532034957ff3985e4a776686f6c90329e2d30ed7b5f85834f12ef272a204c484689b8b6480a933256b8ec64fb274a69d58e4
|
data/config/locales/en.yml
CHANGED
@@ -30,6 +30,10 @@ en:
|
|
30
30
|
default: "[%{service_class_name}] Input `%{input_name}` received value `%{value}`, which is less than `%{option_value}`"
|
31
31
|
max:
|
32
32
|
default: "[%{service_class_name}] Input `%{input_name}` received value `%{value}`, which is greater than `%{option_value}`"
|
33
|
+
multiple_of:
|
34
|
+
default: "[%{service_class_name}] Input `%{input_name}` has the value `%{value}`, which is not a multiple of `%{option_value}`"
|
35
|
+
blank: "[%{service_class_name}] Input `%{input_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
|
36
|
+
divided_by_0: "[%{service_class_name}] Input `%{input_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
|
33
37
|
required:
|
34
38
|
default_error:
|
35
39
|
default: "[%{service_class_name}] Required input `%{input_name}` is missing"
|
@@ -66,6 +70,10 @@ en:
|
|
66
70
|
default: "[%{service_class_name}] Internal attribute `%{internal_name}` received value `%{value}`, which is less than `%{option_value}`"
|
67
71
|
max:
|
68
72
|
default: "[%{service_class_name}] Internal attribute `%{internal_name}` received value `%{value}`, which is greater than `%{option_value}`"
|
73
|
+
multiple_of:
|
74
|
+
default: "[%{service_class_name}] Internal attribute `%{internal_name}` has the value `%{value}`, which is not a multiple of `%{option_value}`"
|
75
|
+
blank: "[%{service_class_name}] Internal attribute `%{internal_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
|
76
|
+
divided_by_0: "[%{service_class_name}] Internal attribute `%{internal_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
|
69
77
|
type:
|
70
78
|
default_error:
|
71
79
|
default: "[%{service_class_name}] Wrong type of internal attribute `%{internal_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
@@ -94,6 +102,10 @@ en:
|
|
94
102
|
default: "[%{service_class_name}] Output attribute `%{output_name}` received value `%{value}`, which is less than `%{option_value}`"
|
95
103
|
max:
|
96
104
|
default: "[%{service_class_name}] Output attribute `%{output_name}` received value `%{value}`, which is greater than `%{option_value}`"
|
105
|
+
multiple_of:
|
106
|
+
default: "[%{service_class_name}] Output attribute `%{output_name}` has the value `%{value}`, which is not a multiple of `%{option_value}`"
|
107
|
+
blank: "[%{service_class_name}] Output attribute `%{output_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
|
108
|
+
divided_by_0: "[%{service_class_name}] Output attribute `%{output_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
|
97
109
|
type:
|
98
110
|
default_error:
|
99
111
|
default: "[%{service_class_name}] Wrong type of output attribute `%{output_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
data/config/locales/ru.yml
CHANGED
@@ -30,6 +30,10 @@ ru:
|
|
30
30
|
default: "[%{service_class_name}] Инпут `%{input_name}` получил значение `%{value}`, которое меньше `%{option_value}`"
|
31
31
|
max:
|
32
32
|
default: "[%{service_class_name}] Инпут `%{input_name}` получил значение `%{value}`, которое больше `%{option_value}`"
|
33
|
+
multiple_of:
|
34
|
+
default: "[%{service_class_name}] Инпут `%{input_name}` имеет значение `%{value}`, которое не кратно `%{option_value}`"
|
35
|
+
blank: "[%{service_class_name}] Инпут `%{input_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
|
36
|
+
divided_by_0: "[%{service_class_name}] Инпут `%{input_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
|
33
37
|
required:
|
34
38
|
default_error:
|
35
39
|
default: "[%{service_class_name}] Обязательный инпут `%{input_name}` отсутствует"
|
@@ -66,6 +70,10 @@ ru:
|
|
66
70
|
default: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` получил значение `%{value}`, которое меньше `%{option_value}`"
|
67
71
|
max:
|
68
72
|
default: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` получил значение `%{value}`, которое больше `%{option_value}`"
|
73
|
+
multiple_of:
|
74
|
+
default: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` имеет значение `%{value}`, которое не кратно `%{option_value}`"
|
75
|
+
blank: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
|
76
|
+
divided_by_0: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
|
69
77
|
type:
|
70
78
|
default_error:
|
71
79
|
default: "[%{service_class_name}] Неправильный тип внутреннего атрибута `%{internal_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
@@ -94,6 +102,10 @@ ru:
|
|
94
102
|
default: "[%{service_class_name}] Выходящий атрибут `%{output_name}` получил значение `%{value}`, которое меньше `%{option_value}`"
|
95
103
|
max:
|
96
104
|
default: "[%{service_class_name}] Выходящий атрибут `%{output_name}` получил значение `%{value}`, которое больше `%{option_value}`"
|
105
|
+
multiple_of:
|
106
|
+
default: "[%{service_class_name}] Выходящий атрибут `%{output_name}` имеет значение `%{value}`, которое не кратно `%{option_value}`"
|
107
|
+
blank: "[%{service_class_name}] Выходящий атрибут `%{output_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
|
108
|
+
divided_by_0: "[%{service_class_name}] Выходящий атрибут `%{output_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
|
97
109
|
type:
|
98
110
|
default_error:
|
99
111
|
default: "[%{service_class_name}] Неправильный тип выходящего атрибута `%{output_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
@@ -75,11 +75,11 @@ module Servactory
|
|
75
75
|
def make(name, position: nil, **options)
|
76
76
|
position = position.presence || next_position
|
77
77
|
|
78
|
-
current_stage = @current_stage.presence || Stages::Stage.new(position:
|
78
|
+
current_stage = @current_stage.presence || Stages::Stage.new(position:)
|
79
79
|
|
80
80
|
current_stage.methods << Action.new(
|
81
81
|
name,
|
82
|
-
position
|
82
|
+
position:,
|
83
83
|
**options
|
84
84
|
)
|
85
85
|
|
@@ -71,19 +71,19 @@ module Servactory
|
|
71
71
|
def default_input_option_helpers
|
72
72
|
Set[
|
73
73
|
Servactory::Maintenance::Attributes::OptionHelper.new(name: :optional, equivalent: { required: false }),
|
74
|
-
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names:
|
74
|
+
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names:)
|
75
75
|
]
|
76
76
|
end
|
77
77
|
|
78
78
|
def default_internal_option_helpers
|
79
79
|
Set[
|
80
|
-
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names:
|
80
|
+
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names:)
|
81
81
|
]
|
82
82
|
end
|
83
83
|
|
84
84
|
def default_output_option_helpers
|
85
85
|
Set[
|
86
|
-
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names:
|
86
|
+
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names:)
|
87
87
|
]
|
88
88
|
end
|
89
89
|
end
|
@@ -8,7 +8,7 @@ module Servactory
|
|
8
8
|
|
9
9
|
_call!(context, **arguments)
|
10
10
|
|
11
|
-
config.result_class.success_for(context:
|
11
|
+
config.result_class.success_for(context:)
|
12
12
|
rescue config.success_class => e
|
13
13
|
config.result_class.success_for(context: e.context)
|
14
14
|
end
|
@@ -18,11 +18,11 @@ module Servactory
|
|
18
18
|
|
19
19
|
_call!(context, **arguments)
|
20
20
|
|
21
|
-
config.result_class.success_for(context:
|
21
|
+
config.result_class.success_for(context:)
|
22
22
|
rescue config.success_class => e
|
23
23
|
config.result_class.success_for(context: e.context)
|
24
24
|
rescue config.failure_class => e
|
25
|
-
config.result_class.failure_for(context
|
25
|
+
config.result_class.failure_for(context:, exception: e)
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
@@ -31,10 +31,10 @@ module Servactory
|
|
31
31
|
context.send(
|
32
32
|
:_call!,
|
33
33
|
incoming_arguments: arguments.symbolize_keys,
|
34
|
-
collection_of_inputs
|
35
|
-
collection_of_internals
|
36
|
-
collection_of_outputs
|
37
|
-
collection_of_stages:
|
34
|
+
collection_of_inputs:,
|
35
|
+
collection_of_internals:,
|
36
|
+
collection_of_outputs:,
|
37
|
+
collection_of_stages:
|
38
38
|
)
|
39
39
|
end
|
40
40
|
end
|
@@ -31,7 +31,7 @@ module Servactory
|
|
31
31
|
|
32
32
|
raise_error_for(:setter, prepared_name)
|
33
33
|
else
|
34
|
-
getter_with(name:
|
34
|
+
getter_with(name:) { raise_error_for(:getter, name) }
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -82,7 +82,7 @@ module Servactory
|
|
82
82
|
else
|
83
83
|
fetch_hash_values_from(
|
84
84
|
value: object.fetch(schema_key, {}),
|
85
|
-
schema_value
|
85
|
+
schema_value:,
|
86
86
|
attribute_required: schema_value.fetch(:required, true)
|
87
87
|
)
|
88
88
|
end
|
@@ -25,9 +25,9 @@ module Servactory
|
|
25
25
|
if name.to_s.end_with?("=")
|
26
26
|
prepared_name = name.to_s.delete("=").to_sym
|
27
27
|
|
28
|
-
setter_with(prepared_name
|
28
|
+
setter_with(prepared_name:, value: args.pop) { raise_error_for(:setter, prepared_name) }
|
29
29
|
else
|
30
|
-
getter_with(name:
|
30
|
+
getter_with(name:) { raise_error_for(:getter, name) }
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -47,7 +47,7 @@ module Servactory
|
|
47
47
|
Servactory::Maintenance::Attributes::Tools::Validation.validate!(
|
48
48
|
context: @context,
|
49
49
|
attribute: internal,
|
50
|
-
value:
|
50
|
+
value:
|
51
51
|
)
|
52
52
|
|
53
53
|
@context.send(:servactory_service_store).assign_internal(internal.name, value)
|
@@ -25,9 +25,9 @@ module Servactory
|
|
25
25
|
if name.to_s.end_with?("=")
|
26
26
|
prepared_name = name.to_s.delete("=").to_sym
|
27
27
|
|
28
|
-
setter_with(prepared_name
|
28
|
+
setter_with(prepared_name:, value: args.pop) { raise_error_for(:setter, prepared_name) }
|
29
29
|
else
|
30
|
-
getter_with(name:
|
30
|
+
getter_with(name:) { raise_error_for(:getter, name) }
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -47,7 +47,7 @@ module Servactory
|
|
47
47
|
Servactory::Maintenance::Attributes::Tools::Validation.validate!(
|
48
48
|
context: @context,
|
49
49
|
attribute: output,
|
50
|
-
value:
|
50
|
+
value:
|
51
51
|
)
|
52
52
|
|
53
53
|
@context.send(:servactory_service_store).assign_output(output.name, value)
|
@@ -23,22 +23,22 @@ module Servactory
|
|
23
23
|
def inputs
|
24
24
|
@inputs ||= Inputs.new(
|
25
25
|
context: self,
|
26
|
-
incoming_arguments
|
27
|
-
collection_of_inputs:
|
26
|
+
incoming_arguments:,
|
27
|
+
collection_of_inputs:
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
31
31
|
def internals
|
32
32
|
@internals ||= Internals.new(
|
33
33
|
context: self,
|
34
|
-
collection_of_internals:
|
34
|
+
collection_of_internals:
|
35
35
|
)
|
36
36
|
end
|
37
37
|
|
38
38
|
def outputs
|
39
39
|
@outputs ||= Outputs.new(
|
40
40
|
context: self,
|
41
|
-
collection_of_outputs:
|
41
|
+
collection_of_outputs:
|
42
42
|
)
|
43
43
|
end
|
44
44
|
|
@@ -48,30 +48,30 @@ module Servactory
|
|
48
48
|
|
49
49
|
def fail_input!(input_name, message:, meta: nil)
|
50
50
|
raise self.class.config.input_exception_class.new(
|
51
|
-
input_name
|
52
|
-
message
|
53
|
-
meta:
|
51
|
+
input_name:,
|
52
|
+
message:,
|
53
|
+
meta:
|
54
54
|
)
|
55
55
|
end
|
56
56
|
|
57
57
|
def fail_internal!(internal_name, message:, meta: nil)
|
58
58
|
raise self.class.config.internal_exception_class.new(
|
59
|
-
internal_name
|
60
|
-
message
|
61
|
-
meta:
|
59
|
+
internal_name:,
|
60
|
+
message:,
|
61
|
+
meta:
|
62
62
|
)
|
63
63
|
end
|
64
64
|
|
65
65
|
def fail_output!(output_name, message:, meta: nil)
|
66
66
|
raise self.class.config.output_exception_class.new(
|
67
|
-
output_name
|
68
|
-
message
|
69
|
-
meta:
|
67
|
+
output_name:,
|
68
|
+
message:,
|
69
|
+
meta:
|
70
70
|
)
|
71
71
|
end
|
72
72
|
|
73
73
|
def fail!(type = :base, message:, meta: nil)
|
74
|
-
raise self.class.config.failure_class.new(type
|
74
|
+
raise self.class.config.failure_class.new(type:, message:, meta:)
|
75
75
|
end
|
76
76
|
|
77
77
|
def fail_result!(service_result)
|
@@ -93,11 +93,11 @@ module Servactory
|
|
93
93
|
collection_of_stages:
|
94
94
|
)
|
95
95
|
call!(
|
96
|
-
incoming_arguments
|
97
|
-
collection_of_inputs
|
98
|
-
collection_of_internals
|
99
|
-
collection_of_outputs
|
100
|
-
collection_of_stages:
|
96
|
+
incoming_arguments:,
|
97
|
+
collection_of_inputs:,
|
98
|
+
collection_of_internals:,
|
99
|
+
collection_of_outputs:,
|
100
|
+
collection_of_stages:
|
101
101
|
)
|
102
102
|
end
|
103
103
|
|
data/lib/servactory/info/dsl.rb
CHANGED
@@ -18,7 +18,7 @@ module Servactory
|
|
18
18
|
[
|
19
19
|
input.name,
|
20
20
|
{
|
21
|
-
actor
|
21
|
+
actor:,
|
22
22
|
types: input.types,
|
23
23
|
required: input.required,
|
24
24
|
default: input.default,
|
@@ -36,7 +36,7 @@ module Servactory
|
|
36
36
|
[
|
37
37
|
internal.name,
|
38
38
|
{
|
39
|
-
actor
|
39
|
+
actor:,
|
40
40
|
types: internal.types,
|
41
41
|
inclusion: inclusion.body,
|
42
42
|
must: must.body
|
@@ -52,7 +52,7 @@ module Servactory
|
|
52
52
|
[
|
53
53
|
output.name,
|
54
54
|
{
|
55
|
-
actor
|
55
|
+
actor:,
|
56
56
|
types: output.types,
|
57
57
|
inclusion: inclusion.body,
|
58
58
|
must: must.body
|
@@ -44,12 +44,12 @@ module Servactory
|
|
44
44
|
@hash_mode_class_names = hash_mode_class_names
|
45
45
|
@option_helpers = option_helpers
|
46
46
|
|
47
|
-
register_options(helpers
|
47
|
+
register_options(helpers:, options:)
|
48
48
|
end
|
49
49
|
# rubocop:enable Style/KeywordParametersOrder
|
50
50
|
|
51
51
|
def method_missing(name, *args, &block)
|
52
|
-
option = @collection_of_options.find_by(name:
|
52
|
+
option = @collection_of_options.find_by(name:)
|
53
53
|
|
54
54
|
return super if option.nil?
|
55
55
|
|
@@ -63,13 +63,13 @@ module Servactory
|
|
63
63
|
def register_options(helpers:, options:) # rubocop:disable Metrics/MethodLength
|
64
64
|
advanced_helpers = options.except(*Servactory::Maintenance::Attributes::Options::Registrar::RESERVED_OPTIONS)
|
65
65
|
|
66
|
-
options = apply_helpers_for_options(helpers
|
67
|
-
options = apply_helpers_for_options(helpers: advanced_helpers, options:
|
66
|
+
options = apply_helpers_for_options(helpers:, options:) if helpers.present?
|
67
|
+
options = apply_helpers_for_options(helpers: advanced_helpers, options:) if advanced_helpers.present?
|
68
68
|
|
69
69
|
options_registrar = Servactory::Maintenance::Attributes::Options::Registrar.register(
|
70
70
|
attribute: self,
|
71
71
|
hash_mode_class_names: @hash_mode_class_names,
|
72
|
-
options
|
72
|
+
options:,
|
73
73
|
features: {
|
74
74
|
required: true,
|
75
75
|
types: true,
|
@@ -26,17 +26,17 @@ module Servactory
|
|
26
26
|
|
27
27
|
def process_input(input)
|
28
28
|
input.options_for_checks.each do |check_key, check_options|
|
29
|
-
process_option(check_key, check_options, input:
|
29
|
+
process_option(check_key, check_options, input:)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
def process_option(check_key, check_options, input:)
|
34
34
|
validation_classes_from(input).each do |validation_class|
|
35
35
|
errors_from_checks = process_validation_class(
|
36
|
-
validation_class
|
37
|
-
input
|
38
|
-
check_key
|
39
|
-
check_options:
|
36
|
+
validation_class:,
|
37
|
+
input:,
|
38
|
+
check_key:,
|
39
|
+
check_options:
|
40
40
|
)
|
41
41
|
|
42
42
|
errors.merge(errors_from_checks.to_a)
|
@@ -53,8 +53,8 @@ module Servactory
|
|
53
53
|
context: @context,
|
54
54
|
attribute: input,
|
55
55
|
value: @incoming_arguments.fetch(input.name, nil),
|
56
|
-
check_key
|
57
|
-
check_options:
|
56
|
+
check_key:,
|
57
|
+
check_options:
|
58
58
|
)
|
59
59
|
end
|
60
60
|
|
@@ -7,7 +7,7 @@ module Servactory
|
|
7
7
|
def self.check(context:, attribute:, value:, check_key:, **)
|
8
8
|
return unless should_be_checked_for?(attribute, check_key)
|
9
9
|
|
10
|
-
new(context
|
10
|
+
new(context:, input: attribute, value:).check
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.should_be_checked_for?(input, check_key)
|
@@ -36,11 +36,11 @@ module Servactory
|
|
36
36
|
@hash_mode_class_names = hash_mode_class_names
|
37
37
|
@option_helpers = option_helpers
|
38
38
|
|
39
|
-
register_options(helpers
|
39
|
+
register_options(helpers:, options:)
|
40
40
|
end
|
41
41
|
|
42
42
|
def method_missing(name, *args, &block)
|
43
|
-
option = @collection_of_options.find_by(name:
|
43
|
+
option = @collection_of_options.find_by(name:)
|
44
44
|
|
45
45
|
return super if option.nil?
|
46
46
|
|
@@ -54,13 +54,13 @@ module Servactory
|
|
54
54
|
def register_options(helpers:, options:) # rubocop:disable Metrics/MethodLength
|
55
55
|
advanced_helpers = options.except(*Servactory::Maintenance::Attributes::Options::Registrar::RESERVED_OPTIONS)
|
56
56
|
|
57
|
-
options = apply_helpers_for_options(helpers
|
58
|
-
options = apply_helpers_for_options(helpers: advanced_helpers, options:
|
57
|
+
options = apply_helpers_for_options(helpers:, options:) if helpers.present?
|
58
|
+
options = apply_helpers_for_options(helpers: advanced_helpers, options:) if advanced_helpers.present?
|
59
59
|
|
60
60
|
options_registrar = Servactory::Maintenance::Attributes::Options::Registrar.register(
|
61
61
|
attribute: self,
|
62
62
|
hash_mode_class_names: @hash_mode_class_names,
|
63
|
-
options
|
63
|
+
options:,
|
64
64
|
features: {
|
65
65
|
types: true,
|
66
66
|
hash: true,
|
@@ -4,7 +4,7 @@ module Servactory
|
|
4
4
|
module Maintenance
|
5
5
|
module Attributes
|
6
6
|
class Option
|
7
|
-
DEFAULT_BODY = ->(key:, body:, message: nil) { { key => body, message:
|
7
|
+
DEFAULT_BODY = ->(key:, body:, message: nil) { { key => body, message: } }
|
8
8
|
|
9
9
|
private_constant :DEFAULT_BODY
|
10
10
|
|
@@ -37,12 +37,12 @@ module Servactory
|
|
37
37
|
@need_for_checks = need_for_checks
|
38
38
|
|
39
39
|
@body = prepare_value_for(
|
40
|
-
original_value
|
41
|
-
options
|
42
|
-
body_key
|
43
|
-
body_value
|
44
|
-
body_fallback
|
45
|
-
with_advanced_mode:
|
40
|
+
original_value:,
|
41
|
+
options:,
|
42
|
+
body_key:,
|
43
|
+
body_value:,
|
44
|
+
body_fallback:,
|
45
|
+
with_advanced_mode:
|
46
46
|
)
|
47
47
|
|
48
48
|
prepare_methods_for(attribute)
|
@@ -69,9 +69,9 @@ module Servactory
|
|
69
69
|
|
70
70
|
prepare_advanced_for(
|
71
71
|
body: options.fetch(@name, DEFAULT_BODY.call(key: body_key, body: body_fallback)),
|
72
|
-
body_key
|
73
|
-
body_value
|
74
|
-
body_fallback:
|
72
|
+
body_key:,
|
73
|
+
body_value:,
|
74
|
+
body_fallback:
|
75
75
|
)
|
76
76
|
end
|
77
77
|
|
@@ -84,18 +84,18 @@ module Servactory
|
|
84
84
|
)
|
85
85
|
if body.is_a?(Hash)
|
86
86
|
if @name == :schema && body.fetch(body_key, nil).nil?
|
87
|
-
DEFAULT_BODY.call(key: body_key, body:
|
87
|
+
DEFAULT_BODY.call(key: body_key, body:)
|
88
88
|
else
|
89
89
|
message = body.fetch(:message, nil)
|
90
90
|
|
91
91
|
DEFAULT_BODY.call(
|
92
92
|
key: body_key,
|
93
93
|
body: body.fetch(body_key, message.present? ? body_value : body_fallback),
|
94
|
-
message:
|
94
|
+
message:
|
95
95
|
)
|
96
96
|
end
|
97
97
|
else
|
98
|
-
DEFAULT_BODY.call(key: body_key, body:
|
98
|
+
DEFAULT_BODY.call(key: body_key, body:)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
# rubocop:enable Metrics/MethodLength
|
@@ -32,9 +32,9 @@ module Servactory
|
|
32
32
|
def process_option(check_key, check_options)
|
33
33
|
validation_classes.each do |validation_class|
|
34
34
|
errors_from_checks = process_validation_class(
|
35
|
-
validation_class
|
36
|
-
check_key
|
37
|
-
check_options:
|
35
|
+
validation_class:,
|
36
|
+
check_key:,
|
37
|
+
check_options:
|
38
38
|
)
|
39
39
|
|
40
40
|
errors.merge(errors_from_checks.to_a)
|
@@ -50,8 +50,8 @@ module Servactory
|
|
50
50
|
context: @context,
|
51
51
|
attribute: @attribute,
|
52
52
|
value: @value,
|
53
|
-
check_key
|
54
|
-
check_options:
|
53
|
+
check_key:,
|
54
|
+
check_options:
|
55
55
|
)
|
56
56
|
end
|
57
57
|
|
@@ -9,13 +9,13 @@ module Servactory
|
|
9
9
|
|
10
10
|
def default_message
|
11
11
|
lambda do |service:, value:, input: nil, internal: nil, output: nil|
|
12
|
-
attribute = Servactory::Utils.define_attribute_with(input
|
12
|
+
attribute = Servactory::Utils.define_attribute_with(input:, internal:, output:)
|
13
13
|
|
14
14
|
service.translate(
|
15
15
|
"#{attribute.i18n_name}.validations.inclusion.default_error",
|
16
16
|
"#{attribute.system_name}_name": attribute.name,
|
17
17
|
"#{attribute.system_name}_inclusion": attribute.inclusion[:in],
|
18
|
-
value:
|
18
|
+
value:
|
19
19
|
)
|
20
20
|
end
|
21
21
|
end
|
@@ -9,28 +9,28 @@ module Servactory
|
|
9
9
|
|
10
10
|
def default_message
|
11
11
|
lambda do |service:, value:, code:, input: nil, internal: nil, output: nil, reason: nil|
|
12
|
-
attribute = Servactory::Utils.define_attribute_with(input
|
12
|
+
attribute = Servactory::Utils.define_attribute_with(input:, internal:, output:)
|
13
13
|
|
14
14
|
service.translate(
|
15
15
|
"#{attribute.i18n_name}.validations.must.default_error",
|
16
16
|
"#{attribute.system_name}_name": attribute.name,
|
17
|
-
value
|
18
|
-
code
|
19
|
-
reason:
|
17
|
+
value:,
|
18
|
+
code:,
|
19
|
+
reason:
|
20
20
|
)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def syntax_error_message
|
25
25
|
lambda do |service:, value:, code:, exception_message:, input: nil, internal: nil, output: nil|
|
26
|
-
attribute = Servactory::Utils.define_attribute_with(input
|
26
|
+
attribute = Servactory::Utils.define_attribute_with(input:, internal:, output:)
|
27
27
|
|
28
28
|
service.translate(
|
29
29
|
"#{attribute.i18n_name}.validations.must.syntax_error",
|
30
30
|
"#{attribute.system_name}_name": attribute.name,
|
31
|
-
value
|
32
|
-
code
|
33
|
-
exception_message:
|
31
|
+
value:,
|
32
|
+
code:,
|
33
|
+
exception_message:
|
34
34
|
)
|
35
35
|
end
|
36
36
|
end
|
@@ -10,11 +10,11 @@ module Servactory
|
|
10
10
|
def default_message
|
11
11
|
lambda do |service:, attribute:, key_name:, expected_type:, given_type:, **|
|
12
12
|
if attribute.hash_mode? && key_name.present?
|
13
|
-
for_hash_mode_with(service
|
14
|
-
expected_type
|
13
|
+
for_hash_mode_with(service:, attribute:, key_name:,
|
14
|
+
expected_type:, given_type:)
|
15
15
|
else
|
16
|
-
for_others_with(service
|
17
|
-
expected_type
|
16
|
+
for_others_with(service:, attribute:,
|
17
|
+
expected_type:, given_type:)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -27,9 +27,9 @@ module Servactory
|
|
27
27
|
if hash_message.is_a?(Proc)
|
28
28
|
hash_message.call(
|
29
29
|
**Servactory::Utils.fetch_hash_with_desired_attribute(attribute),
|
30
|
-
key_name
|
31
|
-
expected_type
|
32
|
-
given_type:
|
30
|
+
key_name:,
|
31
|
+
expected_type:,
|
32
|
+
given_type:
|
33
33
|
)
|
34
34
|
elsif hash_message.is_a?(String) && hash_message.present?
|
35
35
|
hash_message
|
@@ -37,9 +37,9 @@ module Servactory
|
|
37
37
|
service.translate(
|
38
38
|
"#{attribute.i18n_name}.validations.type.default_error.for_hash.wrong_element_type",
|
39
39
|
"#{attribute.system_name}_name": attribute.name,
|
40
|
-
key_name
|
41
|
-
expected_type
|
42
|
-
given_type:
|
40
|
+
key_name:,
|
41
|
+
expected_type:,
|
42
|
+
given_type:
|
43
43
|
)
|
44
44
|
end
|
45
45
|
end
|
@@ -48,8 +48,8 @@ module Servactory
|
|
48
48
|
service.translate(
|
49
49
|
"#{attribute.i18n_name}.validations.type.default_error.default",
|
50
50
|
"#{attribute.system_name}_name": attribute.name,
|
51
|
-
expected_type
|
52
|
-
given_type:
|
51
|
+
expected_type:,
|
52
|
+
given_type:
|
53
53
|
)
|
54
54
|
end
|
55
55
|
end
|