dry-validation 0.1.0 → 0.2.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/.travis.yml +1 -0
- data/CHANGELOG.md +23 -0
- data/README.md +203 -26
- data/config/errors.yml +16 -0
- data/dry-validation.gemspec +1 -0
- data/examples/each.rb +19 -0
- data/examples/form.rb +15 -0
- data/examples/nested.rb +13 -11
- data/lib/dry/validation.rb +5 -0
- data/lib/dry/validation/error_compiler.rb +2 -18
- data/lib/dry/validation/input_type_compiler.rb +78 -0
- data/lib/dry/validation/messages.rb +1 -7
- data/lib/dry/validation/predicates.rb +33 -1
- data/lib/dry/validation/result.rb +8 -0
- data/lib/dry/validation/rule.rb +11 -90
- data/lib/dry/validation/rule/composite.rb +50 -0
- data/lib/dry/validation/rule/each.rb +13 -0
- data/lib/dry/validation/rule/key.rb +17 -0
- data/lib/dry/validation/rule/set.rb +22 -0
- data/lib/dry/validation/rule/value.rb +13 -0
- data/lib/dry/validation/rule_compiler.rb +5 -0
- data/lib/dry/validation/schema.rb +6 -2
- data/lib/dry/validation/schema/definition.rb +4 -0
- data/lib/dry/validation/schema/form.rb +19 -0
- data/lib/dry/validation/schema/key.rb +16 -3
- data/lib/dry/validation/schema/result.rb +29 -0
- data/lib/dry/validation/schema/rule.rb +14 -16
- data/lib/dry/validation/schema/value.rb +14 -2
- data/lib/dry/validation/version.rb +1 -1
- data/spec/integration/custom_error_messages_spec.rb +1 -1
- data/spec/integration/optional_keys_spec.rb +30 -0
- data/spec/integration/schema_form_spec.rb +99 -0
- data/spec/integration/{validation_spec.rb → schema_spec.rb} +40 -13
- data/spec/shared/predicates.rb +1 -1
- data/spec/unit/error_compiler_spec.rb +64 -0
- data/spec/unit/input_type_compiler_spec.rb +205 -0
- data/spec/unit/predicates/bool_spec.rb +34 -0
- data/spec/unit/predicates/date_spec.rb +31 -0
- data/spec/unit/predicates/date_time_spec.rb +31 -0
- data/spec/unit/predicates/decimal_spec.rb +32 -0
- data/spec/unit/predicates/float_spec.rb +31 -0
- data/spec/unit/predicates/{nil_spec.rb → none_spec.rb} +2 -2
- data/spec/unit/predicates/time_spec.rb +31 -0
- data/spec/unit/rule/conjunction_spec.rb +28 -0
- data/spec/unit/rule/disjunction_spec.rb +36 -0
- data/spec/unit/rule/implication_spec.rb +14 -0
- data/spec/unit/rule/value_spec.rb +1 -1
- metadata +60 -6
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec.describe Rule::Composite::Implication do
|
2
|
+
subject(:rule) { Rule::Composite::Implication.new(left, right) }
|
3
|
+
|
4
|
+
let(:left) { Rule::Value.new(:age, Predicates[:int?]) }
|
5
|
+
let(:right) { Rule::Value.new(:age, Predicates[:gt?].curry(18)) }
|
6
|
+
|
7
|
+
describe '#call' do
|
8
|
+
it 'calls left and right' do
|
9
|
+
expect(rule.('19')).to be_success
|
10
|
+
expect(rule.(19)).to be_success
|
11
|
+
expect(rule.(18)).to be_failure
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -3,7 +3,7 @@ require 'dry/validation/rule'
|
|
3
3
|
RSpec.describe Dry::Validation::Rule::Value do
|
4
4
|
include_context 'predicates'
|
5
5
|
|
6
|
-
let(:is_nil) { Dry::Validation::Rule::Value.new(:name,
|
6
|
+
let(:is_nil) { Dry::Validation::Rule::Value.new(:name, none?) }
|
7
7
|
|
8
8
|
let(:is_string) { Dry::Validation::Rule::Value.new(:name, str?) }
|
9
9
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-validation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Holland
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-11-
|
12
|
+
date: 2015-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dry-configurable
|
@@ -59,6 +59,26 @@ dependencies:
|
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0.2'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: dry-data
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.2'
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 0.2.1
|
72
|
+
type: :runtime
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - "~>"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0.2'
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 0.2.1
|
62
82
|
- !ruby/object:Gem::Dependency
|
63
83
|
name: bundler
|
64
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,22 +142,32 @@ files:
|
|
122
142
|
- config/errors.yml
|
123
143
|
- dry-validation.gemspec
|
124
144
|
- examples/basic.rb
|
145
|
+
- examples/each.rb
|
146
|
+
- examples/form.rb
|
125
147
|
- examples/nested.rb
|
126
148
|
- examples/rule_ast.rb
|
127
149
|
- lib/dry-validation.rb
|
128
150
|
- lib/dry/validation.rb
|
129
151
|
- lib/dry/validation/error.rb
|
130
152
|
- lib/dry/validation/error_compiler.rb
|
153
|
+
- lib/dry/validation/input_type_compiler.rb
|
131
154
|
- lib/dry/validation/messages.rb
|
132
155
|
- lib/dry/validation/predicate.rb
|
133
156
|
- lib/dry/validation/predicate_set.rb
|
134
157
|
- lib/dry/validation/predicates.rb
|
135
158
|
- lib/dry/validation/result.rb
|
136
159
|
- lib/dry/validation/rule.rb
|
160
|
+
- lib/dry/validation/rule/composite.rb
|
161
|
+
- lib/dry/validation/rule/each.rb
|
162
|
+
- lib/dry/validation/rule/key.rb
|
163
|
+
- lib/dry/validation/rule/set.rb
|
164
|
+
- lib/dry/validation/rule/value.rb
|
137
165
|
- lib/dry/validation/rule_compiler.rb
|
138
166
|
- lib/dry/validation/schema.rb
|
139
167
|
- lib/dry/validation/schema/definition.rb
|
168
|
+
- lib/dry/validation/schema/form.rb
|
140
169
|
- lib/dry/validation/schema/key.rb
|
170
|
+
- lib/dry/validation/schema/result.rb
|
141
171
|
- lib/dry/validation/schema/rule.rb
|
142
172
|
- lib/dry/validation/schema/value.rb
|
143
173
|
- lib/dry/validation/version.rb
|
@@ -145,15 +175,23 @@ files:
|
|
145
175
|
- spec/fixtures/errors.yml
|
146
176
|
- spec/integration/custom_error_messages_spec.rb
|
147
177
|
- spec/integration/custom_predicates_spec.rb
|
148
|
-
- spec/integration/
|
178
|
+
- spec/integration/optional_keys_spec.rb
|
179
|
+
- spec/integration/schema_form_spec.rb
|
180
|
+
- spec/integration/schema_spec.rb
|
149
181
|
- spec/shared/predicates.rb
|
150
182
|
- spec/spec_helper.rb
|
151
183
|
- spec/unit/error_compiler_spec.rb
|
184
|
+
- spec/unit/input_type_compiler_spec.rb
|
152
185
|
- spec/unit/predicate_spec.rb
|
186
|
+
- spec/unit/predicates/bool_spec.rb
|
187
|
+
- spec/unit/predicates/date_spec.rb
|
188
|
+
- spec/unit/predicates/date_time_spec.rb
|
189
|
+
- spec/unit/predicates/decimal_spec.rb
|
153
190
|
- spec/unit/predicates/empty_spec.rb
|
154
191
|
- spec/unit/predicates/eql_spec.rb
|
155
192
|
- spec/unit/predicates/exclusion_spec.rb
|
156
193
|
- spec/unit/predicates/filled_spec.rb
|
194
|
+
- spec/unit/predicates/float_spec.rb
|
157
195
|
- spec/unit/predicates/format_spec.rb
|
158
196
|
- spec/unit/predicates/gt_spec.rb
|
159
197
|
- spec/unit/predicates/gteq_spec.rb
|
@@ -164,10 +202,14 @@ files:
|
|
164
202
|
- spec/unit/predicates/lteq_spec.rb
|
165
203
|
- spec/unit/predicates/max_size_spec.rb
|
166
204
|
- spec/unit/predicates/min_size_spec.rb
|
167
|
-
- spec/unit/predicates/
|
205
|
+
- spec/unit/predicates/none_spec.rb
|
168
206
|
- spec/unit/predicates/size_spec.rb
|
169
207
|
- spec/unit/predicates/str_spec.rb
|
208
|
+
- spec/unit/predicates/time_spec.rb
|
209
|
+
- spec/unit/rule/conjunction_spec.rb
|
210
|
+
- spec/unit/rule/disjunction_spec.rb
|
170
211
|
- spec/unit/rule/each_spec.rb
|
212
|
+
- spec/unit/rule/implication_spec.rb
|
171
213
|
- spec/unit/rule/key_spec.rb
|
172
214
|
- spec/unit/rule/set_spec.rb
|
173
215
|
- spec/unit/rule/value_spec.rb
|
@@ -200,15 +242,23 @@ test_files:
|
|
200
242
|
- spec/fixtures/errors.yml
|
201
243
|
- spec/integration/custom_error_messages_spec.rb
|
202
244
|
- spec/integration/custom_predicates_spec.rb
|
203
|
-
- spec/integration/
|
245
|
+
- spec/integration/optional_keys_spec.rb
|
246
|
+
- spec/integration/schema_form_spec.rb
|
247
|
+
- spec/integration/schema_spec.rb
|
204
248
|
- spec/shared/predicates.rb
|
205
249
|
- spec/spec_helper.rb
|
206
250
|
- spec/unit/error_compiler_spec.rb
|
251
|
+
- spec/unit/input_type_compiler_spec.rb
|
207
252
|
- spec/unit/predicate_spec.rb
|
253
|
+
- spec/unit/predicates/bool_spec.rb
|
254
|
+
- spec/unit/predicates/date_spec.rb
|
255
|
+
- spec/unit/predicates/date_time_spec.rb
|
256
|
+
- spec/unit/predicates/decimal_spec.rb
|
208
257
|
- spec/unit/predicates/empty_spec.rb
|
209
258
|
- spec/unit/predicates/eql_spec.rb
|
210
259
|
- spec/unit/predicates/exclusion_spec.rb
|
211
260
|
- spec/unit/predicates/filled_spec.rb
|
261
|
+
- spec/unit/predicates/float_spec.rb
|
212
262
|
- spec/unit/predicates/format_spec.rb
|
213
263
|
- spec/unit/predicates/gt_spec.rb
|
214
264
|
- spec/unit/predicates/gteq_spec.rb
|
@@ -219,10 +269,14 @@ test_files:
|
|
219
269
|
- spec/unit/predicates/lteq_spec.rb
|
220
270
|
- spec/unit/predicates/max_size_spec.rb
|
221
271
|
- spec/unit/predicates/min_size_spec.rb
|
222
|
-
- spec/unit/predicates/
|
272
|
+
- spec/unit/predicates/none_spec.rb
|
223
273
|
- spec/unit/predicates/size_spec.rb
|
224
274
|
- spec/unit/predicates/str_spec.rb
|
275
|
+
- spec/unit/predicates/time_spec.rb
|
276
|
+
- spec/unit/rule/conjunction_spec.rb
|
277
|
+
- spec/unit/rule/disjunction_spec.rb
|
225
278
|
- spec/unit/rule/each_spec.rb
|
279
|
+
- spec/unit/rule/implication_spec.rb
|
226
280
|
- spec/unit/rule/key_spec.rb
|
227
281
|
- spec/unit/rule/set_spec.rb
|
228
282
|
- spec/unit/rule/value_spec.rb
|