dry-validation 0.7.4 → 0.8.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/.gitignore +1 -0
- data/.travis.yml +9 -6
- data/CHANGELOG.md +58 -0
- data/Gemfile +3 -3
- data/benchmarks/benchmark_form_invalid.rb +64 -0
- data/benchmarks/benchmark_form_valid.rb +64 -0
- data/benchmarks/profile_schema_call_invalid.rb +20 -0
- data/benchmarks/profile_schema_call_valid.rb +20 -0
- data/benchmarks/profile_schema_definition.rb +14 -0
- data/benchmarks/profile_schema_messages_invalid.rb +20 -0
- data/benchmarks/suite.rb +5 -0
- data/config/errors.yml +12 -5
- data/dry-validation.gemspec +2 -2
- data/examples/basic.rb +2 -2
- data/examples/form.rb +2 -2
- data/examples/json.rb +2 -2
- data/examples/nested.rb +6 -6
- data/lib/dry/validation.rb +22 -3
- data/lib/dry/validation/deprecations.rb +23 -0
- data/lib/dry/validation/error_compiler.rb +31 -11
- data/lib/dry/validation/error_compiler/input.rb +44 -57
- data/lib/dry/validation/hint_compiler.rb +15 -7
- data/lib/dry/validation/input_processor_compiler.rb +13 -6
- data/lib/dry/validation/input_processor_compiler/form.rb +2 -0
- data/lib/dry/validation/input_processor_compiler/sanitizer.rb +1 -1
- data/lib/dry/validation/messages/abstract.rb +9 -1
- data/lib/dry/validation/predicate_registry.rb +101 -0
- data/lib/dry/validation/result.rb +8 -1
- data/lib/dry/validation/schema.rb +110 -44
- data/lib/dry/validation/schema/check.rb +4 -2
- data/lib/dry/validation/schema/deprecated.rb +31 -0
- data/lib/dry/validation/schema/dsl.rb +18 -11
- data/lib/dry/validation/schema/form.rb +1 -0
- data/lib/dry/validation/schema/json.rb +1 -0
- data/lib/dry/validation/schema/key.rb +23 -10
- data/lib/dry/validation/schema/rule.rb +81 -20
- data/lib/dry/validation/schema/value.rb +110 -25
- data/lib/dry/validation/version.rb +1 -1
- data/spec/fixtures/locales/en.yml +1 -0
- data/spec/fixtures/locales/pl.yml +1 -1
- data/spec/integration/custom_error_messages_spec.rb +2 -2
- data/spec/integration/custom_predicates_spec.rb +98 -15
- data/spec/integration/error_compiler_spec.rb +111 -96
- data/spec/integration/form/predicates/array_spec.rb +243 -0
- data/spec/integration/form/predicates/empty_spec.rb +263 -0
- data/spec/integration/form/predicates/eql_spec.rb +327 -0
- data/spec/integration/form/predicates/even_spec.rb +455 -0
- data/spec/integration/form/predicates/excluded_from_spec.rb +455 -0
- data/spec/integration/form/predicates/excludes_spec.rb +391 -0
- data/spec/integration/form/predicates/false_spec.rb +455 -0
- data/spec/integration/form/predicates/filled_spec.rb +467 -0
- data/spec/integration/form/predicates/format_spec.rb +454 -0
- data/spec/integration/form/predicates/gt_spec.rb +519 -0
- data/spec/integration/form/predicates/gteq_spec.rb +519 -0
- data/spec/integration/form/predicates/included_in_spec.rb +455 -0
- data/spec/integration/form/predicates/includes_spec.rb +391 -0
- data/spec/integration/form/predicates/key_spec.rb +75 -0
- data/spec/integration/form/predicates/lt_spec.rb +519 -0
- data/spec/integration/form/predicates/lteq_spec.rb +519 -0
- data/spec/integration/form/predicates/max_size_spec.rb +391 -0
- data/spec/integration/form/predicates/min_size_spec.rb +391 -0
- data/spec/integration/form/predicates/none_spec.rb +265 -0
- data/spec/integration/form/predicates/not_eql_spec.rb +327 -0
- data/spec/integration/form/predicates/odd_spec.rb +455 -0
- data/spec/integration/form/predicates/size/fixed_spec.rb +399 -0
- data/spec/integration/form/predicates/size/range_spec.rb +398 -0
- data/spec/integration/form/predicates/true_spec.rb +455 -0
- data/spec/integration/form/predicates/type_spec.rb +391 -0
- data/spec/integration/hints_spec.rb +90 -4
- data/spec/integration/injecting_rules_spec.rb +2 -2
- data/spec/integration/localized_error_messages_spec.rb +2 -2
- data/spec/integration/messages/i18n_spec.rb +3 -3
- data/spec/integration/optional_keys_spec.rb +3 -3
- data/spec/integration/schema/array_schema_spec.rb +49 -13
- data/spec/integration/schema/check_rules_spec.rb +6 -6
- data/spec/integration/schema/check_with_nested_el_spec.rb +3 -3
- data/spec/integration/schema/check_with_nth_el_spec.rb +1 -1
- data/spec/integration/schema/each_with_set_spec.rb +3 -3
- data/spec/integration/schema/extending_dsl_spec.rb +27 -0
- data/spec/integration/schema/form/explicit_types_spec.rb +182 -0
- data/spec/integration/schema/form_spec.rb +90 -18
- data/spec/integration/schema/hash_schema_spec.rb +47 -0
- data/spec/integration/schema/inheriting_schema_spec.rb +4 -4
- data/spec/integration/schema/input_processor_spec.rb +8 -8
- data/spec/integration/schema/json/explicit_types_spec.rb +157 -0
- data/spec/integration/schema/json_spec.rb +18 -18
- data/spec/integration/schema/macros/confirmation_spec.rb +1 -1
- data/spec/integration/schema/macros/each_spec.rb +177 -43
- data/spec/integration/schema/macros/{required_spec.rb → filled_spec.rb} +34 -6
- data/spec/integration/schema/macros/input_spec.rb +21 -0
- data/spec/integration/schema/macros/maybe_spec.rb +39 -2
- data/spec/integration/schema/macros/value_spec.rb +105 -0
- data/spec/integration/schema/macros/when_spec.rb +28 -8
- data/spec/integration/schema/nested_values_spec.rb +11 -8
- data/spec/integration/schema/not_spec.rb +2 -2
- data/spec/integration/schema/numbers_spec.rb +1 -1
- data/spec/integration/schema/option_with_default_spec.rb +1 -1
- data/spec/integration/schema/predicate_verification_spec.rb +9 -0
- data/spec/integration/schema/predicates/array_spec.rb +295 -0
- data/spec/integration/schema/predicates/custom_spec.rb +103 -0
- data/spec/integration/schema/predicates/empty_spec.rb +263 -0
- data/spec/integration/schema/predicates/eql_spec.rb +327 -0
- data/spec/integration/schema/predicates/even_spec.rb +455 -0
- data/spec/integration/schema/predicates/excluded_from_spec.rb +455 -0
- data/spec/integration/schema/predicates/excludes_spec.rb +391 -0
- data/spec/integration/schema/predicates/filled_spec.rb +467 -0
- data/spec/integration/schema/predicates/format_spec.rb +455 -0
- data/spec/integration/schema/predicates/gt_spec.rb +519 -0
- data/spec/integration/schema/predicates/gteq_spec.rb +519 -0
- data/spec/integration/schema/predicates/hash_spec.rb +69 -0
- data/spec/integration/schema/predicates/included_in_spec.rb +455 -0
- data/spec/integration/schema/predicates/includes_spec.rb +391 -0
- data/spec/integration/schema/predicates/key_spec.rb +88 -0
- data/spec/integration/schema/predicates/lt_spec.rb +520 -0
- data/spec/integration/schema/predicates/lteq_spec.rb +519 -0
- data/spec/integration/schema/predicates/max_size_spec.rb +391 -0
- data/spec/integration/schema/predicates/min_size_spec.rb +391 -0
- data/spec/integration/schema/predicates/none_spec.rb +265 -0
- data/spec/integration/schema/predicates/not_eql_spec.rb +391 -0
- data/spec/integration/schema/predicates/odd_spec.rb +455 -0
- data/spec/integration/schema/predicates/size/fixed_spec.rb +401 -0
- data/spec/integration/schema/predicates/size/range_spec.rb +399 -0
- data/spec/integration/schema/predicates/type_spec.rb +391 -0
- data/spec/integration/schema/reusing_schema_spec.rb +4 -4
- data/spec/integration/schema/using_types_spec.rb +24 -6
- data/spec/integration/schema/xor_spec.rb +2 -2
- data/spec/integration/schema_builders_spec.rb +15 -0
- data/spec/integration/schema_spec.rb +37 -12
- data/spec/shared/predicate_helper.rb +13 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/matchers.rb +38 -0
- data/spec/support/predicates_integration.rb +7 -0
- data/spec/unit/hint_compiler_spec.rb +10 -8
- data/spec/unit/input_processor_compiler/form_spec.rb +45 -43
- data/spec/unit/input_processor_compiler/json_spec.rb +37 -35
- data/spec/unit/predicate_registry_spec.rb +34 -0
- data/spec/unit/schema/key_spec.rb +12 -14
- data/spec/unit/schema/rule_spec.rb +4 -2
- data/spec/unit/schema/value_spec.rb +38 -121
- metadata +150 -16
- data/lib/dry/validation/schema/attr.rb +0 -15
- 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
|
-
|
12
|
+
required(:eat_cake).filled
|
13
13
|
|
14
|
-
|
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
|
-
|
6
|
-
|
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
|
-
|
61
|
+
required(:email).filled
|
34
62
|
|
35
|
-
|
63
|
+
required(:age).maybe(:int?, gt?: 18)
|
36
64
|
|
37
|
-
|
38
|
-
|
65
|
+
required(:address).schema do
|
66
|
+
required(:city).filled(min_size?: 3)
|
39
67
|
|
40
|
-
|
68
|
+
required(:street).filled
|
41
69
|
|
42
|
-
|
43
|
-
key(:name).required
|
44
|
-
key(:code).required
|
45
|
-
end
|
70
|
+
required(:country).schema(CountrySchema)
|
46
71
|
end
|
47
72
|
|
48
|
-
|
73
|
+
required(:phone_numbers).each(:str?)
|
49
74
|
end
|
50
75
|
end
|
51
76
|
|
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
|
@@ -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,
|
12
|
+
[:val, p(:key?, :age)],
|
11
13
|
[
|
12
14
|
:or, [
|
13
|
-
[:key, [:age,
|
15
|
+
[:key, [:age, p(:none?)]],
|
14
16
|
[
|
15
17
|
:and, [
|
16
|
-
[:key, [:age,
|
17
|
-
[:key, [:age,
|
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,
|
28
|
+
[:val, p(:key?, :height)],
|
27
29
|
[
|
28
30
|
:or, [
|
29
|
-
[:attr, [:height,
|
31
|
+
[:attr, [:height, p(:none?)]],
|
30
32
|
[
|
31
33
|
:and, [
|
32
|
-
[:
|
33
|
-
[:
|
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,
|
10
|
+
[:val, p(:key?, :email)],
|
9
11
|
[
|
10
12
|
:and, [
|
11
|
-
[:key, [:email,
|
12
|
-
[:key, [:email,
|
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,
|
21
|
+
[:val, p(:key?, :age)],
|
20
22
|
[
|
21
23
|
:or, [
|
22
|
-
[:key, [:age,
|
24
|
+
[:key, [:age, p(:none?)]],
|
23
25
|
[
|
24
26
|
:and, [
|
25
|
-
[:key, [:age,
|
26
|
-
[:key, [:age,
|
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,
|
36
|
-
[:key, [:address,
|
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,
|
60
|
-
[:key, [:age,
|
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,
|
76
|
-
[:key, [:admin,
|
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,
|
92
|
-
[:key, [:age,
|
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,
|
109
|
+
[:val, p(:key?, :age)],
|
108
110
|
[
|
109
111
|
:or, [
|
110
|
-
[:key, [:age,
|
111
|
-
[:key, [:age,
|
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,
|
130
|
-
[:key, [:lat,
|
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,
|
146
|
-
[:key, [:lat,
|
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,
|
162
|
-
[:key, [:bday,
|
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,
|
178
|
-
[:key, [:bday,
|
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,
|
194
|
-
[:key, [:bday,
|
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,
|
210
|
-
[:key, [:bday,
|
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,
|
226
|
-
[:key, [:admin,
|
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,
|
243
|
+
[:val, p(:key?, :author)],
|
242
244
|
[:set, [
|
243
245
|
[:and, [
|
244
|
-
[:val,
|
246
|
+
[:val, p(:key?, :books)],
|
245
247
|
[
|
246
248
|
:each, [
|
247
249
|
:set, [
|
248
250
|
[
|
249
251
|
:and, [
|
250
|
-
[:val,
|
251
|
-
[:key, [:published,
|
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,
|
280
|
+
[:val, p(:key?, :ids)],
|
279
281
|
[:and, [
|
280
|
-
[:key, [:ids,
|
281
|
-
[:each, [:val,
|
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,
|
300
|
+
[:val, p(:key?, :address)],
|
299
301
|
[
|
300
302
|
:and, [
|
301
|
-
[:key, [:address,
|
303
|
+
[:key, [:address, p(:hash?, [])]],
|
302
304
|
[
|
303
305
|
:set, [
|
304
306
|
[
|
305
307
|
:and, [
|
306
|
-
[:val,
|
307
|
-
[:key, [:street,
|
308
|
+
[:val, p(:key?, :street)],
|
309
|
+
[:key, [:street, p(:filled?, [])]]
|
308
310
|
]
|
309
311
|
]
|
310
312
|
]
|