schemacop 2.4.3 → 2.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +4 -0
- data/VERSION +1 -1
- data/doc/Schemacop.html +1 -1
- data/doc/Schemacop/ArrayValidator.html +1 -1
- data/doc/Schemacop/BooleanValidator.html +1 -1
- data/doc/Schemacop/Caster.html +1 -1
- data/doc/Schemacop/Collector.html +1 -1
- data/doc/Schemacop/Dupper.html +1 -1
- data/doc/Schemacop/Exceptions.html +1 -1
- data/doc/Schemacop/Exceptions/InvalidSchemaError.html +1 -1
- data/doc/Schemacop/Exceptions/ValidationError.html +1 -1
- data/doc/Schemacop/FieldNode.html +1 -1
- data/doc/Schemacop/FloatValidator.html +1 -1
- data/doc/Schemacop/HashValidator.html +10 -6
- data/doc/Schemacop/IntegerValidator.html +1 -1
- data/doc/Schemacop/NilValidator.html +1 -1
- data/doc/Schemacop/Node.html +1 -1
- data/doc/Schemacop/NodeResolver.html +1 -1
- data/doc/Schemacop/NodeSupportingField.html +1 -1
- data/doc/Schemacop/NodeSupportingType.html +1 -1
- data/doc/Schemacop/NodeWithBlock.html +1 -1
- data/doc/Schemacop/NumberValidator.html +1 -1
- data/doc/Schemacop/ObjectValidator.html +1 -1
- data/doc/Schemacop/RootNode.html +1 -1
- data/doc/Schemacop/Schema.html +1 -1
- data/doc/Schemacop/StringValidator.html +1 -1
- data/doc/Schemacop/SymbolValidator.html +1 -1
- data/doc/ScopedEnv.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +5 -2
- data/doc/index.html +5 -2
- data/doc/top-level-namespace.html +1 -1
- data/lib/schemacop/validator/hash_validator.rb +5 -1
- data/schemacop.gemspec +3 -3
- data/test/validator_hash_test.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 563c4f0b6060acb996be2d7ee5b9cd74e09be02a3006792c1b00de306cb2b33e
|
4
|
+
data.tar.gz: 289cfade30ae18f3fbb7a722efe21be5121db73a91cc28e05e9809f47166eff0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d6756524121f90c21388288725453c79c0a1130bceb491ab57bd2b9f8cddc7ead0ee55fa3c33566af092d47f16e137394eabe0c8e1d8f76504ddc534c14ece7
|
7
|
+
data.tar.gz: 2248c109c238409770c16411e669be158e293d8e0cb446c1649186f5e90f053b8cbee1ef6cf3ca0b429ac4c1f12a3c1c83460e8a799c2683a98ad09c8ed5d90a
|
data/CHANGELOG.md
CHANGED
@@ -10,6 +10,11 @@
|
|
10
10
|
### Changes
|
11
11
|
-->
|
12
12
|
|
13
|
+
## 2.4.4 (2020-03-9)
|
14
|
+
|
15
|
+
* Add option `allow_obsolete_keys` to `:hash` validator in order to allow
|
16
|
+
validating arbitrary hashes with dynamic keys not specifiable in schema.
|
17
|
+
|
13
18
|
## 2.4.3 (2020-03-05)
|
14
19
|
|
15
20
|
* Only dup hashes and arrays but not the values when creating the modified
|
data/README.md
CHANGED
@@ -395,6 +395,10 @@ The following types are supported by Schemacop by default:
|
|
395
395
|
|
396
396
|
- accepts a block with an arbitrary number of Field Lines.
|
397
397
|
|
398
|
+
- `allow_obsolete_keys`: If enabled (default `false`), this allows arbitrary
|
399
|
+
keys within your hash. Keys not specified in your schema will not be
|
400
|
+
validated further, but keys specified explicitly are still validated.
|
401
|
+
|
398
402
|
* `:nil`: accepts a Ruby NilClass instance. If you want to allow `nil` as a
|
399
403
|
value in a field, see above for the usage of the suffixes `-!` and `-?` for
|
400
404
|
Field Lines.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.4.
|
1
|
+
2.4.4
|
data/doc/Schemacop.html
CHANGED
@@ -136,7 +136,7 @@
|
|
136
136
|
</div>
|
137
137
|
|
138
138
|
<div id="footer">
|
139
|
-
Generated on
|
139
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
140
140
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
141
141
|
0.9.20 (ruby-2.6.2).
|
142
142
|
</div>
|
@@ -319,7 +319,7 @@
|
|
319
319
|
</div>
|
320
320
|
|
321
321
|
<div id="footer">
|
322
|
-
Generated on
|
322
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
323
323
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
324
324
|
0.9.20 (ruby-2.6.2).
|
325
325
|
</div>
|
@@ -135,7 +135,7 @@
|
|
135
135
|
</div>
|
136
136
|
|
137
137
|
<div id="footer">
|
138
|
-
Generated on
|
138
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
139
139
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
140
140
|
0.9.20 (ruby-2.6.2).
|
141
141
|
</div>
|
data/doc/Schemacop/Caster.html
CHANGED
@@ -369,7 +369,7 @@
|
|
369
369
|
</div>
|
370
370
|
|
371
371
|
<div id="footer">
|
372
|
-
Generated on
|
372
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
373
373
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
374
374
|
0.9.20 (ruby-2.6.2).
|
375
375
|
</div>
|
@@ -777,7 +777,7 @@ called.</p>
|
|
777
777
|
</div>
|
778
778
|
|
779
779
|
<div id="footer">
|
780
|
-
Generated on
|
780
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
781
781
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
782
782
|
0.9.20 (ruby-2.6.2).
|
783
783
|
</div>
|
data/doc/Schemacop/Dupper.html
CHANGED
@@ -204,7 +204,7 @@
|
|
204
204
|
</div>
|
205
205
|
|
206
206
|
<div id="footer">
|
207
|
-
Generated on
|
207
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
208
208
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
209
209
|
0.9.20 (ruby-2.6.2).
|
210
210
|
</div>
|
@@ -105,7 +105,7 @@
|
|
105
105
|
</div>
|
106
106
|
|
107
107
|
<div id="footer">
|
108
|
-
Generated on
|
108
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
109
109
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
110
110
|
0.9.20 (ruby-2.6.2).
|
111
111
|
</div>
|
@@ -114,7 +114,7 @@
|
|
114
114
|
</div>
|
115
115
|
|
116
116
|
<div id="footer">
|
117
|
-
Generated on
|
117
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
118
118
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
119
119
|
0.9.20 (ruby-2.6.2).
|
120
120
|
</div>
|
@@ -114,7 +114,7 @@
|
|
114
114
|
</div>
|
115
115
|
|
116
116
|
<div id="footer">
|
117
|
-
Generated on
|
117
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
118
118
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
119
119
|
0.9.20 (ruby-2.6.2).
|
120
120
|
</div>
|
@@ -411,7 +411,7 @@
|
|
411
411
|
</div>
|
412
412
|
|
413
413
|
<div id="footer">
|
414
|
-
Generated on
|
414
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
415
415
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
416
416
|
0.9.20 (ruby-2.6.2).
|
417
417
|
</div>
|
@@ -148,7 +148,7 @@
|
|
148
148
|
</div>
|
149
149
|
|
150
150
|
<div id="footer">
|
151
|
-
Generated on
|
151
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
152
152
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
153
153
|
0.9.20 (ruby-2.6.2).
|
154
154
|
</div>
|
@@ -215,8 +215,6 @@
|
|
215
215
|
<pre class="lines">
|
216
216
|
|
217
217
|
|
218
|
-
5
|
219
|
-
6
|
220
218
|
7
|
221
219
|
8
|
222
220
|
9
|
@@ -239,10 +237,14 @@
|
|
239
237
|
26
|
240
238
|
27
|
241
239
|
28
|
242
|
-
29
|
240
|
+
29
|
241
|
+
30
|
242
|
+
31
|
243
|
+
32
|
244
|
+
33</pre>
|
243
245
|
</td>
|
244
246
|
<td>
|
245
|
-
<pre class="code"><span class="info file"># File 'lib/schemacop/validator/hash_validator.rb', line
|
247
|
+
<pre class="code"><span class="info file"># File 'lib/schemacop/validator/hash_validator.rb', line 7</span>
|
246
248
|
|
247
249
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate'>validate</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_collector'>collector</span><span class='rparen'>)</span>
|
248
250
|
<span class='kw'>super</span>
|
@@ -263,7 +265,9 @@
|
|
263
265
|
|
264
266
|
<span class='id identifier rubyid_obsolete_keys'>obsolete_keys</span> <span class='op'>=</span> <span class='id identifier rubyid_data_keys'>data_keys</span> <span class='op'>-</span> <span class='id identifier rubyid_allowed_fields'>allowed_fields</span>
|
265
267
|
|
266
|
-
<span class='
|
268
|
+
<span class='kw'>unless</span> <span class='id identifier rubyid_option?'>option?</span><span class='lparen'>(</span><span class='symbol'>:allow_obsolete_keys</span><span class='rparen'>)</span>
|
269
|
+
<span class='id identifier rubyid_collector'>collector</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Obsolete keys: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_obsolete_keys'>obsolete_keys</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_obsolete_keys'>obsolete_keys</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span>
|
270
|
+
<span class='kw'>end</span>
|
267
271
|
|
268
272
|
<span class='ivar'>@fields</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
|
269
273
|
<span class='id identifier rubyid_field'>field</span><span class='period'>.</span><span class='id identifier rubyid_validate'>validate</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_collector'>collector</span><span class='rparen'>)</span>
|
@@ -279,7 +283,7 @@
|
|
279
283
|
</div>
|
280
284
|
|
281
285
|
<div id="footer">
|
282
|
-
Generated on
|
286
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
283
287
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
284
288
|
0.9.20 (ruby-2.6.2).
|
285
289
|
</div>
|
@@ -148,7 +148,7 @@
|
|
148
148
|
</div>
|
149
149
|
|
150
150
|
<div id="footer">
|
151
|
-
Generated on
|
151
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
152
152
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
153
153
|
0.9.20 (ruby-2.6.2).
|
154
154
|
</div>
|
@@ -135,7 +135,7 @@
|
|
135
135
|
</div>
|
136
136
|
|
137
137
|
<div id="footer">
|
138
|
-
Generated on
|
138
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
139
139
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
140
140
|
0.9.20 (ruby-2.6.2).
|
141
141
|
</div>
|
data/doc/Schemacop/Node.html
CHANGED
@@ -1428,7 +1428,7 @@
|
|
1428
1428
|
</div>
|
1429
1429
|
|
1430
1430
|
<div id="footer">
|
1431
|
-
Generated on
|
1431
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
1432
1432
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1433
1433
|
0.9.20 (ruby-2.6.2).
|
1434
1434
|
</div>
|
@@ -248,7 +248,7 @@
|
|
248
248
|
</div>
|
249
249
|
|
250
250
|
<div id="footer">
|
251
|
-
Generated on
|
251
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
252
252
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
253
253
|
0.9.20 (ruby-2.6.2).
|
254
254
|
</div>
|
@@ -580,7 +580,7 @@
|
|
580
580
|
</div>
|
581
581
|
|
582
582
|
<div id="footer">
|
583
|
-
Generated on
|
583
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
584
584
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
585
585
|
0.9.20 (ruby-2.6.2).
|
586
586
|
</div>
|
@@ -602,7 +602,7 @@ as it formerly was the case in the constructor.</p>
|
|
602
602
|
</div>
|
603
603
|
|
604
604
|
<div id="footer">
|
605
|
-
Generated on
|
605
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
606
606
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
607
607
|
0.9.20 (ruby-2.6.2).
|
608
608
|
</div>
|
@@ -279,7 +279,7 @@
|
|
279
279
|
</div>
|
280
280
|
|
281
281
|
<div id="footer">
|
282
|
-
Generated on
|
282
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
283
283
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
284
284
|
0.9.20 (ruby-2.6.2).
|
285
285
|
</div>
|
@@ -222,7 +222,7 @@
|
|
222
222
|
</div>
|
223
223
|
|
224
224
|
<div id="footer">
|
225
|
-
Generated on
|
225
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
226
226
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
227
227
|
0.9.20 (ruby-2.6.2).
|
228
228
|
</div>
|
@@ -288,7 +288,7 @@
|
|
288
288
|
</div>
|
289
289
|
|
290
290
|
<div id="footer">
|
291
|
-
Generated on
|
291
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
292
292
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
293
293
|
0.9.20 (ruby-2.6.2).
|
294
294
|
</div>
|
data/doc/Schemacop/RootNode.html
CHANGED
@@ -161,7 +161,7 @@
|
|
161
161
|
</div>
|
162
162
|
|
163
163
|
<div id="footer">
|
164
|
-
Generated on
|
164
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
165
165
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
166
166
|
0.9.20 (ruby-2.6.2).
|
167
167
|
</div>
|
data/doc/Schemacop/Schema.html
CHANGED
@@ -689,7 +689,7 @@ this exception is thrown.</p>
|
|
689
689
|
</div>
|
690
690
|
|
691
691
|
<div id="footer">
|
692
|
-
Generated on
|
692
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
693
693
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
694
694
|
0.9.20 (ruby-2.6.2).
|
695
695
|
</div>
|
@@ -285,7 +285,7 @@
|
|
285
285
|
</div>
|
286
286
|
|
287
287
|
<div id="footer">
|
288
|
-
Generated on
|
288
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
289
289
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
290
290
|
0.9.20 (ruby-2.6.2).
|
291
291
|
</div>
|
@@ -135,7 +135,7 @@
|
|
135
135
|
</div>
|
136
136
|
|
137
137
|
<div id="footer">
|
138
|
-
Generated on
|
138
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
139
139
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
140
140
|
0.9.20 (ruby-2.6.2).
|
141
141
|
</div>
|
data/doc/ScopedEnv.html
CHANGED
@@ -341,7 +341,7 @@
|
|
341
341
|
</div>
|
342
342
|
|
343
343
|
<div id="footer">
|
344
|
-
Generated on
|
344
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
345
345
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
346
346
|
0.9.20 (ruby-2.6.2).
|
347
347
|
</div>
|
data/doc/_index.html
CHANGED
@@ -369,7 +369,7 @@
|
|
369
369
|
</div>
|
370
370
|
|
371
371
|
<div id="footer">
|
372
|
-
Generated on
|
372
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
373
373
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
374
374
|
0.9.20 (ruby-2.6.2).
|
375
375
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -446,7 +446,10 @@ validator_array_test#test_multiple_arrays</p>
|
|
446
446
|
<ul>
|
447
447
|
<li><code>:hash</code> accepts a Ruby Hash or an <code>ActiveSupport::HashWithIndifferentAccess</code>.</li>
|
448
448
|
</ul></li>
|
449
|
-
<li><p>accepts a block with an arbitrary number of Field Lines.</p>
|
449
|
+
<li><p>accepts a block with an arbitrary number of Field Lines.</p></li>
|
450
|
+
<li><p><code>allow_obsolete_keys</code>: If enabled (default <code>false</code>), this allows arbitrary
|
451
|
+
keys within your hash. Keys not specified in your schema will not be
|
452
|
+
validated further, but keys specified explicitly are still validated.</p>
|
450
453
|
|
451
454
|
<ul>
|
452
455
|
<li><code>:nil</code>: accepts a Ruby NilClass instance. If you want to allow <code>nil</code> as a
|
@@ -808,7 +811,7 @@ file</p></li>
|
|
808
811
|
</div></div>
|
809
812
|
|
810
813
|
<div id="footer">
|
811
|
-
Generated on
|
814
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
812
815
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
813
816
|
0.9.20 (ruby-2.6.2).
|
814
817
|
</div>
|
data/doc/index.html
CHANGED
@@ -446,7 +446,10 @@ validator_array_test#test_multiple_arrays</p>
|
|
446
446
|
<ul>
|
447
447
|
<li><code>:hash</code> accepts a Ruby Hash or an <code>ActiveSupport::HashWithIndifferentAccess</code>.</li>
|
448
448
|
</ul></li>
|
449
|
-
<li><p>accepts a block with an arbitrary number of Field Lines.</p>
|
449
|
+
<li><p>accepts a block with an arbitrary number of Field Lines.</p></li>
|
450
|
+
<li><p><code>allow_obsolete_keys</code>: If enabled (default <code>false</code>), this allows arbitrary
|
451
|
+
keys within your hash. Keys not specified in your schema will not be
|
452
|
+
validated further, but keys specified explicitly are still validated.</p>
|
450
453
|
|
451
454
|
<ul>
|
452
455
|
<li><code>:nil</code>: accepts a Ruby NilClass instance. If you want to allow <code>nil</code> as a
|
@@ -808,7 +811,7 @@ file</p></li>
|
|
808
811
|
</div></div>
|
809
812
|
|
810
813
|
<div id="footer">
|
811
|
-
Generated on
|
814
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
812
815
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
813
816
|
0.9.20 (ruby-2.6.2).
|
814
817
|
</div>
|
@@ -102,7 +102,7 @@
|
|
102
102
|
</div>
|
103
103
|
|
104
104
|
<div id="footer">
|
105
|
-
Generated on
|
105
|
+
Generated on Mon Mar 9 10:36:30 2020 by
|
106
106
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
107
107
|
0.9.20 (ruby-2.6.2).
|
108
108
|
</div>
|
@@ -2,6 +2,8 @@ module Schemacop
|
|
2
2
|
class HashValidator < NodeSupportingField
|
3
3
|
register symbols: :hash, klasses: Hash
|
4
4
|
|
5
|
+
option :allow_obsolete_keys
|
6
|
+
|
5
7
|
def validate(data, collector)
|
6
8
|
super
|
7
9
|
|
@@ -21,7 +23,9 @@ module Schemacop
|
|
21
23
|
|
22
24
|
obsolete_keys = data_keys - allowed_fields
|
23
25
|
|
24
|
-
|
26
|
+
unless option?(:allow_obsolete_keys)
|
27
|
+
collector.error "Obsolete keys: #{obsolete_keys.inspect}." if obsolete_keys.any?
|
28
|
+
end
|
25
29
|
|
26
30
|
@fields.values.each do |field|
|
27
31
|
field.validate(data, collector)
|
data/schemacop.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: schemacop 2.4.
|
2
|
+
# stub: schemacop 2.4.4 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "schemacop".freeze
|
6
|
-
s.version = "2.4.
|
6
|
+
s.version = "2.4.4"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Sitrox".freeze]
|
11
|
-
s.date = "2020-03-
|
11
|
+
s.date = "2020-03-09"
|
12
12
|
s.files = [".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, ".travis.yml".freeze, ".yardopts".freeze, "CHANGELOG.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "RUBY_VERSION".freeze, "Rakefile".freeze, "VERSION".freeze, "doc/Schemacop.html".freeze, "doc/Schemacop/ArrayValidator.html".freeze, "doc/Schemacop/BooleanValidator.html".freeze, "doc/Schemacop/Caster.html".freeze, "doc/Schemacop/Collector.html".freeze, "doc/Schemacop/Dupper.html".freeze, "doc/Schemacop/Exceptions.html".freeze, "doc/Schemacop/Exceptions/InvalidSchemaError.html".freeze, "doc/Schemacop/Exceptions/ValidationError.html".freeze, "doc/Schemacop/FieldNode.html".freeze, "doc/Schemacop/FloatValidator.html".freeze, "doc/Schemacop/HashValidator.html".freeze, "doc/Schemacop/IntegerValidator.html".freeze, "doc/Schemacop/NilValidator.html".freeze, "doc/Schemacop/Node.html".freeze, "doc/Schemacop/NodeResolver.html".freeze, "doc/Schemacop/NodeSupportingField.html".freeze, "doc/Schemacop/NodeSupportingType.html".freeze, "doc/Schemacop/NodeWithBlock.html".freeze, "doc/Schemacop/NumberValidator.html".freeze, "doc/Schemacop/ObjectValidator.html".freeze, "doc/Schemacop/RootNode.html".freeze, "doc/Schemacop/Schema.html".freeze, "doc/Schemacop/StringValidator.html".freeze, "doc/Schemacop/SymbolValidator.html".freeze, "doc/ScopedEnv.html".freeze, "doc/_index.html".freeze, "doc/class_list.html".freeze, "doc/css/common.css".freeze, "doc/css/full_list.css".freeze, "doc/css/style.css".freeze, "doc/file.README.html".freeze, "doc/file_list.html".freeze, "doc/frames.html".freeze, "doc/index.html".freeze, "doc/inheritance.graphml".freeze, "doc/inheritance.pdf".freeze, "doc/js/app.js".freeze, "doc/js/full_list.js".freeze, "doc/js/jquery.js".freeze, "doc/method_list.html".freeze, "doc/top-level-namespace.html".freeze, "lib/schemacop.rb".freeze, "lib/schemacop/caster.rb".freeze, "lib/schemacop/collector.rb".freeze, "lib/schemacop/dupper.rb".freeze, "lib/schemacop/exceptions.rb".freeze, "lib/schemacop/field_node.rb".freeze, "lib/schemacop/node.rb".freeze, "lib/schemacop/node_resolver.rb".freeze, "lib/schemacop/node_supporting_field.rb".freeze, "lib/schemacop/node_supporting_type.rb".freeze, "lib/schemacop/node_with_block.rb".freeze, "lib/schemacop/root_node.rb".freeze, "lib/schemacop/schema.rb".freeze, "lib/schemacop/scoped_env.rb".freeze, "lib/schemacop/validator/array_validator.rb".freeze, "lib/schemacop/validator/boolean_validator.rb".freeze, "lib/schemacop/validator/float_validator.rb".freeze, "lib/schemacop/validator/hash_validator.rb".freeze, "lib/schemacop/validator/integer_validator.rb".freeze, "lib/schemacop/validator/nil_validator.rb".freeze, "lib/schemacop/validator/number_validator.rb".freeze, "lib/schemacop/validator/object_validator.rb".freeze, "lib/schemacop/validator/string_validator.rb".freeze, "lib/schemacop/validator/symbol_validator.rb".freeze, "schemacop.gemspec".freeze, "test/casting_test.rb".freeze, "test/collector_test.rb".freeze, "test/custom_check_test.rb".freeze, "test/custom_if_test.rb".freeze, "test/defaults_test.rb".freeze, "test/nil_dis_allow_test.rb".freeze, "test/node_resolver_test.rb".freeze, "test/short_forms_test.rb".freeze, "test/test_helper.rb".freeze, "test/types_test.rb".freeze, "test/validator_array_test.rb".freeze, "test/validator_boolean_test.rb".freeze, "test/validator_float_test.rb".freeze, "test/validator_hash_test.rb".freeze, "test/validator_integer_test.rb".freeze, "test/validator_nil_test.rb".freeze, "test/validator_number_test.rb".freeze, "test/validator_object_test.rb".freeze, "test/validator_string_test.rb".freeze, "test/validator_symbol_test.rb".freeze]
|
13
13
|
s.homepage = "https://github.com/sitrox/schemacop".freeze
|
14
14
|
s.licenses = ["MIT".freeze]
|
data/test/validator_hash_test.rb
CHANGED
@@ -21,6 +21,28 @@ module Schemacop
|
|
21
21
|
assert_verr { s.validate!(one: 3, three: true) }
|
22
22
|
end
|
23
23
|
|
24
|
+
def test_allow_obsolete_keys
|
25
|
+
s = Schema.new do
|
26
|
+
type :hash, allow_obsolete_keys: true
|
27
|
+
end
|
28
|
+
|
29
|
+
assert_nothing_raised { s.validate!(foo: :bar) }
|
30
|
+
assert_equal({ foo: { bar: :baz } }, s.validate!(foo: { bar: :baz }))
|
31
|
+
|
32
|
+
assert_verr { s.validate!(3) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_allow_obsolete_keys_with_substructore
|
36
|
+
s = Schema.new do
|
37
|
+
type :hash, allow_obsolete_keys: true do
|
38
|
+
req :foo
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
assert_nothing_raised { s.validate!(foo: :bar, bar: :baz) }
|
43
|
+
assert_verr { s.validate!(bar: :baz) }
|
44
|
+
end
|
45
|
+
|
24
46
|
def test_nested
|
25
47
|
s = Schema.new do
|
26
48
|
type :hash do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schemacop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sitrox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|