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
@@ -5,6 +5,7 @@ module Dry
5
5
  class Schema::Form < Schema
6
6
  configure do |config|
7
7
  config.input_processor = :form
8
+ config.hash_type = :symbolized
8
9
  end
9
10
  end
10
11
  end
@@ -5,6 +5,7 @@ module Dry
5
5
  class Schema::JSON < Schema
6
6
  configure do |config|
7
7
  config.input_processor = :json
8
+ config.hash_type = :symbolized
8
9
  end
9
10
  end
10
11
  end
@@ -22,28 +22,41 @@ module Dry
22
22
  [type, [name, super]]
23
23
  end
24
24
 
25
+ def each(*predicates, &block)
26
+ create_rule([type, [name, value.each(*predicates, &block).to_ast]])
27
+ end
28
+
25
29
  def hash?(&block)
26
- val = Value[name]
27
- val.instance_eval(&block)
30
+ predicate = registry[:hash?]
28
31
 
29
- rule = create_rule([:val, [:predicate, [:hash?, []]]])
30
- .and(create_rule([type, [name, [:set, val.rules.map(&:to_ast)]]]))
32
+ if block
33
+ val = value.instance_eval(&block)
31
34
 
32
- add_rule(rule)
35
+ rule = create_rule([:val, predicate.to_ast])
36
+ .and(create_rule([type, [name, val.to_ast]]))
37
+
38
+ add_rule(rule)
39
+ rule
40
+ else
41
+ add_rule(create_rule([:val, predicate.to_ast]))
42
+ end
43
+ end
33
44
 
34
- rule
45
+ def value
46
+ Value[name, registry: registry]
35
47
  end
36
48
 
37
49
  private
38
50
 
39
51
  def method_missing(meth, *args, &block)
40
- predicate = [:predicate, [meth, args]]
52
+ registry.ensure_valid_predicate(meth, args)
53
+ predicate = registry[meth].curry(*args)
41
54
 
42
55
  if block
43
- val = Value[name].instance_eval(&block)
44
- add_rule(create_rule([:and, [[:val, predicate], val.to_ast]]))
56
+ val = value.instance_eval(&block)
57
+ add_rule(create_rule([:and, [[:val, predicate.to_ast], val.to_ast]]))
45
58
  else
46
- rule = create_rule([type, [name, predicate]])
59
+ rule = create_rule([type, [name, predicate.to_ast]])
47
60
  add_rule(rule)
48
61
  rule
49
62
  end
@@ -1,7 +1,17 @@
1
+ require 'dry/validation/deprecations'
2
+
1
3
  module Dry
2
4
  module Validation
3
5
  class Schema
4
6
  class Rule < BasicObject
7
+ include ::Dry::Validation::Deprecations
8
+
9
+ INVALID_PREDICATES = {
10
+ value: [],
11
+ maybe: [:empty?, :none?],
12
+ filled: [:empty?, :filled?],
13
+ }.freeze
14
+
5
15
  attr_reader :name, :node, :type, :target, :deps, :options
6
16
 
7
17
  def initialize(node, options = {})
@@ -20,27 +30,76 @@ module Dry
20
30
 
21
31
  def schema(other = nil, &block)
22
32
  schema = Schema.create_class(target, other, &block)
33
+
34
+ if schema.config.type_specs
35
+ target.type_map[name] = schema.type_map
36
+ end
37
+
23
38
  rule = __send__(type, key(:hash?).and(key(schema)))
24
39
  add_rule(rule)
25
40
  end
26
41
 
42
+ def schema?
43
+ target.schema?
44
+ end
45
+
46
+ def registry
47
+ target.registry
48
+ end
49
+
50
+ def type_map
51
+ target.type_map
52
+ end
53
+
54
+ def type_map?
55
+ target.type_map?
56
+ end
57
+
27
58
  def required(*predicates)
28
- rule = ([key(:filled?)] + infer_predicates(predicates)).reduce(:and)
59
+ warn 'required is deprecated - use filled instead.'
29
60
 
30
- add_rule(__send__(type, rule))
61
+ filled(*predicates)
31
62
  end
32
63
 
33
- def maybe(*predicates)
64
+ def filled(*predicates, &block)
65
+ left = ([key(:filled?)] + infer_predicates(predicates, :filled)).reduce(:and)
66
+
34
67
  rule =
35
- if predicates.size > 0
36
- key(:none?).or(infer_predicates(predicates).reduce(:and))
68
+ if block
69
+ left.and(Key[name, registry: registry].instance_eval(&block))
37
70
  else
38
- key(:none?).or(key(:filled?))
71
+ left
39
72
  end
40
73
 
41
74
  add_rule(__send__(type, rule))
42
75
  end
43
76
 
77
+ def value(*predicates, &block)
78
+ if predicates.empty? && !block
79
+ ::Kernel.raise ::ArgumentError, "wrong number of arguments (given 0, expected at least 1)"
80
+ end
81
+
82
+ from_predicates = infer_predicates(predicates, :value).reduce(:and)
83
+ from_block = block ? Key[name, registry: registry].instance_eval(&block) : nil
84
+
85
+ rule = [from_predicates, from_block].compact.reduce(:and)
86
+
87
+ add_rule(__send__(type, rule))
88
+ end
89
+
90
+ def maybe(*predicates, &block)
91
+ left = key(:none?)
92
+
93
+ from_predicates = infer_predicates(predicates, :maybe).reduce(:and)
94
+ from_block = block ? Key[name, registry: registry].instance_eval(&block) : nil
95
+
96
+ right = [from_predicates, from_block].compact.reduce(:and) || key(:filled?)
97
+
98
+ rule = left.or(right)
99
+
100
+ add_rule(__send__(type, rule))
101
+ end
102
+
44
103
  def each(*predicates, &block)
45
104
  rule = target.each(*predicates, &block)
46
105
  add_rule(__send__(type, new([target.type, [name, rule.to_ast]])))
@@ -98,10 +157,15 @@ module Dry
98
157
  end
99
158
  alias_method :>, :then
100
159
 
101
- def infer_predicates(predicates)
160
+ def infer_predicates(predicates, macro = nil)
102
161
  predicates.map do |predicate|
103
162
  name, *args = ::Kernel.Array(predicate).first
104
- key(name, args)
163
+
164
+ if macro && INVALID_PREDICATES[macro].include?(name)
165
+ ::Kernel.raise InvalidSchemaError, "you can't use #{name} predicate with #{macro} macro"
166
+ else
167
+ key(name, args)
168
+ end
105
169
  end
106
170
  end
107
171
 
@@ -111,19 +175,16 @@ module Dry
111
175
 
112
176
  private
113
177
 
114
- def key(predicate, args = [])
115
- node =
116
- if predicate.is_a?(::Symbol)
117
- [target.type, [name, [:predicate, [predicate, args]]]]
118
- elsif predicate.respond_to?(:rule)
119
- [target.type, [name, [:type, predicate]]]
120
- elsif predicate.is_a?(::Class) && predicate < ::Dry::Types::Struct
121
- [target.type, [name, [:schema, Schema.create_class(target, predicate)]]]
122
- else
123
- [target.type, [name, predicate.to_ast]]
124
- end
178
+ def method_missing(meth, *args, &block)
179
+ if target.predicate?(meth)
180
+ target.__send__(meth, *args, &block)
181
+ else
182
+ super
183
+ end
184
+ end
125
185
 
126
- new(node)
186
+ def key(predicate, args = [])
187
+ new(target.node(predicate, *args))
127
188
  end
128
189
 
129
190
  def new(node)
@@ -4,31 +4,45 @@ module Dry
4
4
  module Validation
5
5
  class Schema
6
6
  class Value < DSL
7
- attr_reader :type, :schema_class
7
+ attr_reader :type, :schema_class, :schema, :type_map
8
8
 
9
9
  def initialize(options = {})
10
10
  super
11
11
  @type = options.fetch(:type, :key)
12
12
  @schema_class = options.fetch(:schema_class, ::Class.new(Schema))
13
+ @options = options.merge(type: @type, schema_class: @schema_class)
14
+ @type_map = parent && parent.root? ? parent.type_map : {}
13
15
  end
14
16
 
15
- def configure(&block)
16
- klass = ::Class.new(schema_class, &block)
17
- @schema_class = klass
17
+ def predicates(mod)
18
+ @registry = options[:registry] = schema_class.predicates(mod)
19
+ end
20
+
21
+ def input(type)
22
+ schema_class.config.input = type
18
23
  self
19
24
  end
20
25
 
21
- def root?
22
- name.nil?
26
+ def key(name, &block)
27
+ warn 'key is deprecated - use required instead.'
28
+
29
+ required(name, &block)
23
30
  end
24
31
 
25
- def class
26
- Value
32
+ def required(name, type_spec = nil, &block)
33
+ rule = define(name, Key, &block)
34
+
35
+ if type_spec
36
+ type_map[name] = type_spec
37
+ end
38
+
39
+ rule
27
40
  end
28
41
 
29
42
  def schema(other = nil, &block)
30
- schema = Schema.create_class(self, other, &block)
31
- hash?.and(schema)
43
+ @schema = Schema.create_class(self, other, &block)
44
+ type_map.update(@schema.type_map)
45
+ hash?.and(@schema)
32
46
  end
33
47
 
34
48
  def each(*predicates, &block)
@@ -36,14 +50,21 @@ module Dry
36
50
 
37
51
  right =
38
52
  if predicates.size > 0
39
- inferred = predicates
40
- .reduce(Value.new) { |a, e| a.__send__(*::Kernel.Array(e)) }
41
-
42
- create_rule([:each, inferred.to_ast])
53
+ create_rule([:each, infer_predicates(predicates, new).to_ast])
43
54
  else
44
- val = Value[name].instance_eval(&block)
45
-
46
- create_rule([:each, [:set, val.rule_ast]])
55
+ val = Value[
56
+ name, registry: registry, schema_class: schema_class.clone
57
+ ].instance_eval(&block)
58
+
59
+ if val.type_map?
60
+ if root?
61
+ @type_map = [val.type_map]
62
+ else
63
+ type_map[name] = [val.type_map]
64
+ end
65
+ end
66
+
67
+ create_rule([:each, val.to_ast])
47
68
  end
48
69
 
49
70
  rule = left.and(right)
@@ -54,10 +75,9 @@ module Dry
54
75
  end
55
76
 
56
77
  def when(*predicates, &block)
57
- left = predicates
58
- .reduce(Check[path, type: type]) { |a, e| a.__send__(*::Kernel.Array(e)) }
78
+ left = infer_predicates(predicates, Check[path, type: type, registry: registry])
59
79
 
60
- right = Value.new(type: type)
80
+ right = Value.new(type: type, registry: registry)
61
81
  right.instance_eval(&block)
62
82
 
63
83
  add_check(left.then(create_rule(right.to_ast)))
@@ -67,11 +87,11 @@ module Dry
67
87
 
68
88
  def rule(id = nil, **options, &block)
69
89
  if id
70
- val = Value[id]
90
+ val = Value[id, registry: registry]
71
91
  res = val.instance_exec(&block)
72
92
  else
73
93
  id, deps = options.to_a.first
74
- val = Value[id]
94
+ val = Value[id, registry: registry]
75
95
  res = val.instance_exec(*deps.map { |name| val.value(name) }, &block)
76
96
  end
77
97
 
@@ -87,20 +107,85 @@ module Dry
87
107
  end
88
108
 
89
109
  def value(name)
90
- check(name, rules: rules)
110
+ check(name, registry: registry, rules: rules)
91
111
  end
92
112
 
93
113
  def check(name, options = {})
94
114
  Check[name, options.merge(type: type)]
95
115
  end
96
116
 
117
+ def configure(&block)
118
+ klass = ::Class.new(schema_class, &block)
119
+ @schema_class = klass
120
+ @registry = klass.registry
121
+ self
122
+ end
123
+
124
+ def root?
125
+ name.nil?
126
+ end
127
+
128
+ def type_map?
129
+ ! type_map.empty?
130
+ end
131
+
132
+ def schema?
133
+ ! @schema.nil?
134
+ end
135
+
136
+ def class
137
+ Value
138
+ end
139
+
140
+ def new
141
+ self.class.new(registry: registry, schema_class: schema_class.clone)
142
+ end
143
+
144
+ def key?(name)
145
+ create_rule([:val, registry[:key?].curry(name).to_ast])
146
+ end
147
+
148
+ def predicate(name, *args)
149
+ registry.ensure_valid_predicate(name, args)
150
+ registry[name].curry(*args)
151
+ end
152
+
153
+ def node(input, *args)
154
+ if input.is_a?(::Symbol)
155
+ [type, [name, predicate(input, *args).to_ast]]
156
+ elsif input.respond_to?(:rule)
157
+ [type, [name, [:type, input]]]
158
+ elsif input.is_a?(::Class) && input < ::Dry::Types::Struct
159
+ [type, [name, [:schema, Schema.create_class(self, input)]]]
160
+ elsif input.is_a?(Schema)
161
+ [type, [name, schema(input).to_ast]]
162
+ else
163
+ [type, [name, input.to_ast]]
164
+ end
165
+ end
166
+
97
167
  private
98
168
 
169
+ def infer_predicates(predicates, infer_on)
170
+ predicates.map { |predicate|
171
+ name, *args = ::Kernel.Array(predicate).first
172
+
173
+ if name.is_a?(Schema)
174
+ infer_on.schema(name)
175
+ else
176
+ infer_on.__send__(name, *args)
177
+ end
178
+ }.reduce(:and)
179
+ end
180
+
99
181
  def method_missing(meth, *args, &block)
100
- val_rule = create_rule([:val, [:predicate, [meth, args]]])
182
+ val_rule = create_rule([:val, predicate(meth, *args).to_ast])
101
183
 
102
184
  if block
103
- val = Value.new.instance_eval(&block)
185
+ val = new.instance_eval(&block)
186
+
187
+ type_map.update(val.type_map) if val.type_map?
188
+
104
189
  new_rule = create_rule([:and, [val_rule.to_ast, val.to_ast]])
105
190
 
106
191
  add_rule(new_rule)
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Validation
3
- VERSION = '0.7.4'.freeze
3
+ VERSION = '0.8.0'.freeze
4
4
  end
5
5
  end
@@ -3,3 +3,4 @@ en:
3
3
  rules:
4
4
  email:
5
5
  filled?: "Please provide your email"
6
+ email?: "must be an email"
@@ -3,7 +3,7 @@ pl:
3
3
  filled?: "nie może być pusty"
4
4
  size?:
5
5
  arg:
6
- default: "wielkość musi być równa %{num}"
6
+ default: "wielkość musi być równa %{size}"
7
7
  range: "wielkość musi być między %{left} a %{right}"
8
8
  rules:
9
9
  email:
@@ -18,7 +18,7 @@ RSpec.describe Dry::Validation do
18
18
  config.messages_file = SPEC_ROOT.join('fixtures/locales/en.yml')
19
19
  end
20
20
 
21
- key(:email, &:filled?)
21
+ required(:email, &:filled?)
22
22
  end
23
23
  end
24
24
 
@@ -38,7 +38,7 @@ RSpec.describe Dry::Validation do
38
38
  config.messages = :i18n
39
39
  end
40
40
 
41
- key(:email, &:filled?)
41
+ required(:email, &:filled?)
42
42
  end
43
43
  end
44
44