dry-validation 0.7.4 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +9 -6
  4. data/CHANGELOG.md +58 -0
  5. data/Gemfile +3 -3
  6. data/benchmarks/benchmark_form_invalid.rb +64 -0
  7. data/benchmarks/benchmark_form_valid.rb +64 -0
  8. data/benchmarks/profile_schema_call_invalid.rb +20 -0
  9. data/benchmarks/profile_schema_call_valid.rb +20 -0
  10. data/benchmarks/profile_schema_definition.rb +14 -0
  11. data/benchmarks/profile_schema_messages_invalid.rb +20 -0
  12. data/benchmarks/suite.rb +5 -0
  13. data/config/errors.yml +12 -5
  14. data/dry-validation.gemspec +2 -2
  15. data/examples/basic.rb +2 -2
  16. data/examples/form.rb +2 -2
  17. data/examples/json.rb +2 -2
  18. data/examples/nested.rb +6 -6
  19. data/lib/dry/validation.rb +22 -3
  20. data/lib/dry/validation/deprecations.rb +23 -0
  21. data/lib/dry/validation/error_compiler.rb +31 -11
  22. data/lib/dry/validation/error_compiler/input.rb +44 -57
  23. data/lib/dry/validation/hint_compiler.rb +15 -7
  24. data/lib/dry/validation/input_processor_compiler.rb +13 -6
  25. data/lib/dry/validation/input_processor_compiler/form.rb +2 -0
  26. data/lib/dry/validation/input_processor_compiler/sanitizer.rb +1 -1
  27. data/lib/dry/validation/messages/abstract.rb +9 -1
  28. data/lib/dry/validation/predicate_registry.rb +101 -0
  29. data/lib/dry/validation/result.rb +8 -1
  30. data/lib/dry/validation/schema.rb +110 -44
  31. data/lib/dry/validation/schema/check.rb +4 -2
  32. data/lib/dry/validation/schema/deprecated.rb +31 -0
  33. data/lib/dry/validation/schema/dsl.rb +18 -11
  34. data/lib/dry/validation/schema/form.rb +1 -0
  35. data/lib/dry/validation/schema/json.rb +1 -0
  36. data/lib/dry/validation/schema/key.rb +23 -10
  37. data/lib/dry/validation/schema/rule.rb +81 -20
  38. data/lib/dry/validation/schema/value.rb +110 -25
  39. data/lib/dry/validation/version.rb +1 -1
  40. data/spec/fixtures/locales/en.yml +1 -0
  41. data/spec/fixtures/locales/pl.yml +1 -1
  42. data/spec/integration/custom_error_messages_spec.rb +2 -2
  43. data/spec/integration/custom_predicates_spec.rb +98 -15
  44. data/spec/integration/error_compiler_spec.rb +111 -96
  45. data/spec/integration/form/predicates/array_spec.rb +243 -0
  46. data/spec/integration/form/predicates/empty_spec.rb +263 -0
  47. data/spec/integration/form/predicates/eql_spec.rb +327 -0
  48. data/spec/integration/form/predicates/even_spec.rb +455 -0
  49. data/spec/integration/form/predicates/excluded_from_spec.rb +455 -0
  50. data/spec/integration/form/predicates/excludes_spec.rb +391 -0
  51. data/spec/integration/form/predicates/false_spec.rb +455 -0
  52. data/spec/integration/form/predicates/filled_spec.rb +467 -0
  53. data/spec/integration/form/predicates/format_spec.rb +454 -0
  54. data/spec/integration/form/predicates/gt_spec.rb +519 -0
  55. data/spec/integration/form/predicates/gteq_spec.rb +519 -0
  56. data/spec/integration/form/predicates/included_in_spec.rb +455 -0
  57. data/spec/integration/form/predicates/includes_spec.rb +391 -0
  58. data/spec/integration/form/predicates/key_spec.rb +75 -0
  59. data/spec/integration/form/predicates/lt_spec.rb +519 -0
  60. data/spec/integration/form/predicates/lteq_spec.rb +519 -0
  61. data/spec/integration/form/predicates/max_size_spec.rb +391 -0
  62. data/spec/integration/form/predicates/min_size_spec.rb +391 -0
  63. data/spec/integration/form/predicates/none_spec.rb +265 -0
  64. data/spec/integration/form/predicates/not_eql_spec.rb +327 -0
  65. data/spec/integration/form/predicates/odd_spec.rb +455 -0
  66. data/spec/integration/form/predicates/size/fixed_spec.rb +399 -0
  67. data/spec/integration/form/predicates/size/range_spec.rb +398 -0
  68. data/spec/integration/form/predicates/true_spec.rb +455 -0
  69. data/spec/integration/form/predicates/type_spec.rb +391 -0
  70. data/spec/integration/hints_spec.rb +90 -4
  71. data/spec/integration/injecting_rules_spec.rb +2 -2
  72. data/spec/integration/localized_error_messages_spec.rb +2 -2
  73. data/spec/integration/messages/i18n_spec.rb +3 -3
  74. data/spec/integration/optional_keys_spec.rb +3 -3
  75. data/spec/integration/schema/array_schema_spec.rb +49 -13
  76. data/spec/integration/schema/check_rules_spec.rb +6 -6
  77. data/spec/integration/schema/check_with_nested_el_spec.rb +3 -3
  78. data/spec/integration/schema/check_with_nth_el_spec.rb +1 -1
  79. data/spec/integration/schema/each_with_set_spec.rb +3 -3
  80. data/spec/integration/schema/extending_dsl_spec.rb +27 -0
  81. data/spec/integration/schema/form/explicit_types_spec.rb +182 -0
  82. data/spec/integration/schema/form_spec.rb +90 -18
  83. data/spec/integration/schema/hash_schema_spec.rb +47 -0
  84. data/spec/integration/schema/inheriting_schema_spec.rb +4 -4
  85. data/spec/integration/schema/input_processor_spec.rb +8 -8
  86. data/spec/integration/schema/json/explicit_types_spec.rb +157 -0
  87. data/spec/integration/schema/json_spec.rb +18 -18
  88. data/spec/integration/schema/macros/confirmation_spec.rb +1 -1
  89. data/spec/integration/schema/macros/each_spec.rb +177 -43
  90. data/spec/integration/schema/macros/{required_spec.rb → filled_spec.rb} +34 -6
  91. data/spec/integration/schema/macros/input_spec.rb +21 -0
  92. data/spec/integration/schema/macros/maybe_spec.rb +39 -2
  93. data/spec/integration/schema/macros/value_spec.rb +105 -0
  94. data/spec/integration/schema/macros/when_spec.rb +28 -8
  95. data/spec/integration/schema/nested_values_spec.rb +11 -8
  96. data/spec/integration/schema/not_spec.rb +2 -2
  97. data/spec/integration/schema/numbers_spec.rb +1 -1
  98. data/spec/integration/schema/option_with_default_spec.rb +1 -1
  99. data/spec/integration/schema/predicate_verification_spec.rb +9 -0
  100. data/spec/integration/schema/predicates/array_spec.rb +295 -0
  101. data/spec/integration/schema/predicates/custom_spec.rb +103 -0
  102. data/spec/integration/schema/predicates/empty_spec.rb +263 -0
  103. data/spec/integration/schema/predicates/eql_spec.rb +327 -0
  104. data/spec/integration/schema/predicates/even_spec.rb +455 -0
  105. data/spec/integration/schema/predicates/excluded_from_spec.rb +455 -0
  106. data/spec/integration/schema/predicates/excludes_spec.rb +391 -0
  107. data/spec/integration/schema/predicates/filled_spec.rb +467 -0
  108. data/spec/integration/schema/predicates/format_spec.rb +455 -0
  109. data/spec/integration/schema/predicates/gt_spec.rb +519 -0
  110. data/spec/integration/schema/predicates/gteq_spec.rb +519 -0
  111. data/spec/integration/schema/predicates/hash_spec.rb +69 -0
  112. data/spec/integration/schema/predicates/included_in_spec.rb +455 -0
  113. data/spec/integration/schema/predicates/includes_spec.rb +391 -0
  114. data/spec/integration/schema/predicates/key_spec.rb +88 -0
  115. data/spec/integration/schema/predicates/lt_spec.rb +520 -0
  116. data/spec/integration/schema/predicates/lteq_spec.rb +519 -0
  117. data/spec/integration/schema/predicates/max_size_spec.rb +391 -0
  118. data/spec/integration/schema/predicates/min_size_spec.rb +391 -0
  119. data/spec/integration/schema/predicates/none_spec.rb +265 -0
  120. data/spec/integration/schema/predicates/not_eql_spec.rb +391 -0
  121. data/spec/integration/schema/predicates/odd_spec.rb +455 -0
  122. data/spec/integration/schema/predicates/size/fixed_spec.rb +401 -0
  123. data/spec/integration/schema/predicates/size/range_spec.rb +399 -0
  124. data/spec/integration/schema/predicates/type_spec.rb +391 -0
  125. data/spec/integration/schema/reusing_schema_spec.rb +4 -4
  126. data/spec/integration/schema/using_types_spec.rb +24 -6
  127. data/spec/integration/schema/xor_spec.rb +2 -2
  128. data/spec/integration/schema_builders_spec.rb +15 -0
  129. data/spec/integration/schema_spec.rb +37 -12
  130. data/spec/shared/predicate_helper.rb +13 -0
  131. data/spec/spec_helper.rb +10 -0
  132. data/spec/support/matchers.rb +38 -0
  133. data/spec/support/predicates_integration.rb +7 -0
  134. data/spec/unit/hint_compiler_spec.rb +10 -8
  135. data/spec/unit/input_processor_compiler/form_spec.rb +45 -43
  136. data/spec/unit/input_processor_compiler/json_spec.rb +37 -35
  137. data/spec/unit/predicate_registry_spec.rb +34 -0
  138. data/spec/unit/schema/key_spec.rb +12 -14
  139. data/spec/unit/schema/rule_spec.rb +4 -2
  140. data/spec/unit/schema/value_spec.rb +38 -121
  141. metadata +150 -16
  142. data/lib/dry/validation/schema/attr.rb +0 -15
  143. data/spec/integration/attr_spec.rb +0 -122
@@ -9,9 +9,9 @@ RSpec.describe 'Schema with xor rules' do
9
9
  end
10
10
  end
11
11
 
12
- key(:eat_cake).required
12
+ required(:eat_cake).filled
13
13
 
14
- key(:have_cake).required
14
+ required(:have_cake).filled
15
15
 
16
16
  rule(:be_reasonable) do
17
17
  value(:eat_cake).eql?('yes!') ^ value(:have_cake).eql?('yes!')
@@ -0,0 +1,15 @@
1
+ RSpec.describe 'Building schemas' do
2
+ describe 'Dry::Validation.Schema' do
3
+ it 'builds a schema class with custom predicate set' do
4
+ predicates = Module.new do
5
+ include Dry::Logic::Predicates
6
+
7
+ predicate(:zomg?) { true }
8
+ end
9
+
10
+ schema = Dry::Validation.Schema(predicates: predicates, build: false)
11
+
12
+ expect(schema.predicates.key?(:zomg?)).to be(true)
13
+ end
14
+ end
15
+ end
@@ -2,8 +2,13 @@ RSpec.describe Dry::Validation::Schema, 'defining key-based schema' do
2
2
  describe 'with a flat structure' do
3
3
  subject(:schema) do
4
4
  Dry::Validation.Schema do
5
- key(:email).required
6
- key(:age) { none? | (int? & gt?(18)) }
5
+ configure do
6
+ config.input_processor = :form
7
+ config.type_specs = true
8
+ end
9
+
10
+ required(:email, :string).filled
11
+ required(:age, [:nil, :int]) { none? | (int? & gt?(18)) }
7
12
  end
8
13
  end
9
14
 
@@ -25,27 +30,47 @@ RSpec.describe Dry::Validation::Schema, 'defining key-based schema' do
25
30
 
26
31
  expect(result.to_a).to eql([[:email, 'jane@doe'], [:age, 19]])
27
32
  end
33
+
34
+ describe '#type_map' do
35
+ it 'returns key=>type map' do
36
+ expect(schema.type_map).to eql(
37
+ email: Types::String, age: Types::Form::Nil | Types::Form::Int
38
+ )
39
+ end
40
+
41
+ it 'uses type_map for input processor when it is not empty' do
42
+ expect(schema.(email: 'jane@doe.org', age: '18').to_h).to eql(
43
+ email: 'jane@doe.org', age: 18
44
+ )
45
+ end
46
+ end
28
47
  end
29
48
 
30
49
  describe 'with nested structures' do
31
50
  subject(:schema) do
51
+ class CountrySchema
52
+ def self.schema
53
+ Dry::Validation.Schema do
54
+ required(:name).filled
55
+ required(:code).filled
56
+ end
57
+ end
58
+ end
59
+
32
60
  Dry::Validation.Schema do
33
- key(:email).required
61
+ required(:email).filled
34
62
 
35
- key(:age).maybe(:int?, gt?: 18)
63
+ required(:age).maybe(:int?, gt?: 18)
36
64
 
37
- key(:address).schema do
38
- key(:city).required(min_size?: 3)
65
+ required(:address).schema do
66
+ required(:city).filled(min_size?: 3)
39
67
 
40
- key(:street).required
68
+ required(:street).filled
41
69
 
42
- key(:country).schema do
43
- key(:name).required
44
- key(:code).required
45
- end
70
+ required(:country).schema(CountrySchema)
46
71
  end
47
72
 
48
- key(:phone_numbers).each(:str?)
73
+ required(:phone_numbers).each(:str?)
49
74
  end
50
75
  end
51
76
 
@@ -0,0 +1,13 @@
1
+ shared_context 'predicate helper' do
2
+ def p(name, *args)
3
+ predicates[name].curry(*args).to_ast
4
+ end
5
+
6
+ let!(:predicates) do
7
+ Module.new {
8
+ include Dry::Logic::Predicates
9
+
10
+ predicate(:email?) { |value| true }
11
+ }
12
+ end
13
+ end
data/spec/spec_helper.rb CHANGED
@@ -19,6 +19,14 @@ Dir[SPEC_ROOT.join('support/**/*.rb')].each(&method(:require))
19
19
 
20
20
  include Dry::Validation
21
21
 
22
+ module Types
23
+ include Dry::Types.module
24
+ end
25
+
26
+ Dry::Validation::Deprecations.configure do |config|
27
+ config.logger = Logger.new(SPEC_ROOT.join('../log/deprecations.log'))
28
+ end
29
+
22
30
  RSpec.configure do |config|
23
31
  config.disable_monkey_patching!
24
32
 
@@ -28,4 +36,6 @@ RSpec.configure do |config|
28
36
  I18n.backend.reload!
29
37
  end
30
38
  end
39
+
40
+ config.include PredicatesIntegration
31
41
  end
@@ -0,0 +1,38 @@
1
+ require 'rspec/expectations'
2
+
3
+ RSpec::Matchers.define :be_successful do
4
+ match do |actual|
5
+ actual.success? &&
6
+ actual.messages.empty?
7
+ end
8
+
9
+ failure_message do |actual|
10
+ "expected that #{actual.inspect} would be successful"
11
+ end
12
+
13
+ failure_message_when_negated do |actual|
14
+ "expected that #{actual.inspect} would NOT be successful"
15
+ end
16
+ end
17
+
18
+ RSpec::Matchers.define :be_failing do |messages|
19
+ match do |actual|
20
+ messages = case messages
21
+ when Hash
22
+ messages
23
+ else
24
+ Array(messages)
25
+ end
26
+
27
+ !actual.success? &&
28
+ actual.messages.fetch(:foo) == messages
29
+ end
30
+
31
+ failure_message do |actual|
32
+ "expected that #{actual.inspect} would be failing (#{messages.inspect})"
33
+ end
34
+
35
+ failure_message_when_negated do |actual|
36
+ "expected that #{actual.inspect} would NOT be failing"
37
+ end
38
+ end
@@ -0,0 +1,7 @@
1
+ module PredicatesIntegration
2
+ private
3
+
4
+ def result
5
+ schema.(input)
6
+ end
7
+ end
@@ -3,18 +3,20 @@ require 'dry/validation/hint_compiler'
3
3
  RSpec.describe HintCompiler, '#call' do
4
4
  subject(:compiler) { HintCompiler.new(Messages.default, rules: rules) }
5
5
 
6
+ include_context 'predicate helper'
7
+
6
8
  let(:rules) do
7
9
  [
8
10
  [
9
11
  :and, [
10
- [:val, [:predicate, [:key?, [:age]]]],
12
+ [:val, p(:key?, :age)],
11
13
  [
12
14
  :or, [
13
- [:key, [:age, [:predicate, [:none?, []]]]],
15
+ [:key, [:age, p(:none?)]],
14
16
  [
15
17
  :and, [
16
- [:key, [:age, [:predicate, [:int?, []]]]],
17
- [:key, [:age, [:predicate, [:gt?, [18]]]]]
18
+ [:key, [:age, p(:int?)]],
19
+ [:key, [:age, p(:gt?, 18)]]
18
20
  ]
19
21
  ]
20
22
  ]
@@ -23,14 +25,14 @@ RSpec.describe HintCompiler, '#call' do
23
25
  ],
24
26
  [
25
27
  :and, [
26
- [:val, [:predicate, [:attr?, [:height]]]],
28
+ [:val, p(:key?, :height)],
27
29
  [
28
30
  :or, [
29
- [:attr, [:height, [:predicate, [:none?, []]]]],
31
+ [:attr, [:height, p(:none?)]],
30
32
  [
31
33
  :and, [
32
- [:attr, [:height, [:predicate, [:int?, []]]]],
33
- [:attr, [:height, [:predicate, [:gt?, [180]]]]]
34
+ [:key, [:height, p(:int?)]],
35
+ [:key, [:height, p(:gt?, 180)]]
34
36
  ]
35
37
  ]
36
38
  ]
@@ -1,29 +1,31 @@
1
1
  RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
2
2
  subject(:compiler) { Dry::Validation::InputProcessorCompiler::Form.new }
3
3
 
4
+ include_context 'predicate helper'
5
+
4
6
  let(:rule_ast) do
5
7
  [
6
8
  [
7
9
  :and, [
8
- [:val, [:predicate, [:key?, [:email]]]],
10
+ [:val, p(:key?, :email)],
9
11
  [
10
12
  :and, [
11
- [:key, [:email, [:predicate, [:str?, []]]]],
12
- [:key, [:email, [:predicate, [:filled?, []]]]]
13
+ [:key, [:email, p(:str?)]],
14
+ [:key, [:email, p(:filled?)]]
13
15
  ]
14
16
  ]
15
17
  ]
16
18
  ],
17
19
  [
18
20
  :and, [
19
- [:val, [:predicate, [:key?, [:age]]]],
21
+ [:val, p(:key?, :age)],
20
22
  [
21
23
  :or, [
22
- [:key, [:age, [:predicate, [:none?, []]]]],
24
+ [:key, [:age, p(:none?)]],
23
25
  [
24
26
  :and, [
25
- [:key, [:age, [:predicate, [:int?, []]]]],
26
- [:key, [:age, [:predicate, [:filled?, []]]]]
27
+ [:key, [:age, p(:int?)]],
28
+ [:key, [:age, p(:filled?)]]
27
29
  ]
28
30
  ]
29
31
  ]
@@ -32,8 +34,8 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
32
34
  ],
33
35
  [
34
36
  :and, [
35
- [:val, [:predicate, [:key?, [:address]]]],
36
- [:key, [:address, [:predicate, [:str?, []]]]]
37
+ [:val, p(:key?, :address)],
38
+ [:key, [:address, p(:str?)]]
37
39
  ]
38
40
  ]
39
41
  ]
@@ -56,8 +58,8 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
56
58
  [
57
59
  :and,
58
60
  [
59
- [:val, [:predicate, [:key?, [:age]]]],
60
- [:key, [:age, [:predicate, [:type?, [Fixnum]]]]]
61
+ [:val, p(:key?, :age)],
62
+ [:key, [:age, p(:type?, Fixnum)]]
61
63
  ]
62
64
  ]
63
65
  ]
@@ -72,8 +74,8 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
72
74
  [
73
75
  :and,
74
76
  [
75
- [:val, [:predicate, [:key?, [:admin]]]],
76
- [:key, [:admin, [:predicate, [:type?, ['Form::Bool']]]]]
77
+ [:val, p(:key?, :admin)],
78
+ [:key, [:admin, p(:type?, 'Form::Bool')]]
77
79
  ]
78
80
  ]
79
81
  ]
@@ -88,8 +90,8 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
88
90
  [
89
91
  :and,
90
92
  [
91
- [:val, [:predicate, [:key?, [:age]]]],
92
- [:key, [:age, [:predicate, [:int?, []]]]],
93
+ [:val, p(:key?, :age)],
94
+ [:key, [:age, p(:int?)]],
93
95
  ]
94
96
  ]
95
97
  ]
@@ -104,11 +106,11 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
104
106
  [
105
107
  :and,
106
108
  [
107
- [:val, [:predicate, [:key?, [:age]]]],
109
+ [:val, p(:key?, :age)],
108
110
  [
109
111
  :or, [
110
- [:key, [:age, [:predicate, [:none?, []]]]],
111
- [:key, [:age, [:predicate, [:int?, []]]]],
112
+ [:key, [:age, p(:none?)]],
113
+ [:key, [:age, p(:int?)]],
112
114
  ]
113
115
  ]
114
116
  ]
@@ -126,8 +128,8 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
126
128
  [
127
129
  :and,
128
130
  [
129
- [:val, [:predicate, [:key?, [:lat]]]],
130
- [:key, [:lat, [:predicate, [:float?, []]]]],
131
+ [:val, p(:key?, :lat)],
132
+ [:key, [:lat, p(:float?)]],
131
133
  ]
132
134
  ]
133
135
  ]
@@ -142,8 +144,8 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
142
144
  [
143
145
  :and,
144
146
  [
145
- [:val, [:predicate, [:key?, [:lat]]]],
146
- [:key, [:lat, [:predicate, [:decimal?, []]]]],
147
+ [:val, p(:key?, :lat)],
148
+ [:key, [:lat, p(:decimal?, [])]],
147
149
  ]
148
150
  ]
149
151
  ]
@@ -158,8 +160,8 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
158
160
  [
159
161
  :and,
160
162
  [
161
- [:val, [:predicate, [:key?, [:bday]]]],
162
- [:key, [:bday, [:predicate, [:date?, []]]]],
163
+ [:val, p(:key?, :bday)],
164
+ [:key, [:bday, p(:date?, [])]],
163
165
  ]
164
166
  ]
165
167
  ]
@@ -174,8 +176,8 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
174
176
  [
175
177
  :and,
176
178
  [
177
- [:val, [:predicate, [:key?, [:bday]]]],
178
- [:key, [:bday, [:predicate, [:date_time?, []]]]],
179
+ [:val, p(:key?, :bday)],
180
+ [:key, [:bday, p(:date_time?, [])]],
179
181
  ]
180
182
  ]
181
183
  ]
@@ -190,8 +192,8 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
190
192
  [
191
193
  :and,
192
194
  [
193
- [:val, [:predicate, [:key?, [:bday]]]],
194
- [:key, [:bday, [:predicate, [:time?, []]]]],
195
+ [:val, p(:key?, :bday)],
196
+ [:key, [:bday, p(:time?, [])]],
195
197
  ]
196
198
  ]
197
199
  ]
@@ -206,8 +208,8 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
206
208
  [
207
209
  :and,
208
210
  [
209
- [:val, [:predicate, [:key?, [:bday]]]],
210
- [:key, [:bday, [:predicate, [:time?, []]]]],
211
+ [:val, p(:key?, :bday)],
212
+ [:key, [:bday, p(:time?, [])]],
211
213
  ]
212
214
  ]
213
215
  ]
@@ -222,8 +224,8 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
222
224
  [
223
225
  :and,
224
226
  [
225
- [:val, [:predicate, [:key?, [:admin]]]],
226
- [:key, [:admin, [:predicate, [:bool?, []]]]],
227
+ [:val, p(:key?, :admin)],
228
+ [:key, [:admin, p(:bool?, [])]],
227
229
  ]
228
230
  ]
229
231
  ]
@@ -238,17 +240,17 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
238
240
  rule_ast = [
239
241
  [
240
242
  :and, [
241
- [:val, [:predicate, [:key?, [:author]]]],
243
+ [:val, p(:key?, :author)],
242
244
  [:set, [
243
245
  [:and, [
244
- [:val, [:predicate, [:key?, [:books]]]],
246
+ [:val, p(:key?, :books)],
245
247
  [
246
248
  :each, [
247
249
  :set, [
248
250
  [
249
251
  :and, [
250
- [:val, [:predicate, [:key?, [:published]]]],
251
- [:key, [:published, [:predicate, [:bool?, []]]]]
252
+ [:val, p(:key?, :published)],
253
+ [:key, [:published, p(:bool?, [])]]
252
254
  ]
253
255
  ]
254
256
  ]
@@ -275,10 +277,10 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
275
277
  rule_ast = [
276
278
  [
277
279
  :and, [
278
- [:val, [:predicate, [:key?, [:ids]]]],
280
+ [:val, p(:key?, :ids)],
279
281
  [:and, [
280
- [:key, [:ids, [:predicate, [:array?, []]]]],
281
- [:each, [:val, [:predicate, [:int?, []]]]]
282
+ [:key, [:ids, p(:array?, [])]],
283
+ [:each, [:val, p(:int?, [])]]
282
284
  ]]
283
285
  ]
284
286
  ]
@@ -295,16 +297,16 @@ RSpec.describe Dry::Validation::InputProcessorCompiler::Form, '#call' do
295
297
  rule_ast = [
296
298
  [
297
299
  :and, [
298
- [:val, [:predicate, [:key?, [:address]]]],
300
+ [:val, p(:key?, :address)],
299
301
  [
300
302
  :and, [
301
- [:key, [:address, [:predicate, [:hash?, []]]]],
303
+ [:key, [:address, p(:hash?, [])]],
302
304
  [
303
305
  :set, [
304
306
  [
305
307
  :and, [
306
- [:val, [:predicate, [:key?, [:street]]]],
307
- [:key, [:street, [:predicate, [:filled?, []]]]]
308
+ [:val, p(:key?, :street)],
309
+ [:key, [:street, p(:filled?, [])]]
308
310
  ]
309
311
  ]
310
312
  ]