schemacop 2.4.6 → 2.4.7
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/VERSION +1 -1
- data/doc/Schemacop.html +3 -3
- 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 +1 -1
- 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 +1 -1
- data/doc/index.html +1 -1
- data/doc/top-level-namespace.html +1 -1
- data/lib/schemacop.rb +3 -2
- data/schemacop.gemspec +3 -3
- data/test/casting_test.rb +18 -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: b84cfd3771e9bf279d88c3c13d79432951bcd37f19db4f4ea9e275b45b4f70d5
|
4
|
+
data.tar.gz: 7aef2cd86d1c4e42b0242137d721d5b9ab0f808083436fcee15fdf72e252336d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bffa5cdc99b8d6e5aa478b182f87041aa9cf4616d62459fa386829a154c6fd2fde2c75d4c8504741e26eac6ab3478cad811fa33b363580bed7b5c1f04ff4ad6
|
7
|
+
data.tar.gz: 7bb43ad27b2966851c30803a96b0b733b7ba9062784edd08fbb94aadc52c5c61e1142455bab0ad7d8a46c2c8e21572d26e3625f649ece2d18d468c2ea94b495b
|
data/CHANGELOG.md
CHANGED
@@ -10,6 +10,11 @@
|
|
10
10
|
### Changes
|
11
11
|
-->
|
12
12
|
|
13
|
+
## 2.4.7 (2020-07-02)
|
14
|
+
|
15
|
+
* Return nil when casting an empty string to an Integer or a Float,
|
16
|
+
such that these cases can then be handled by the `opt` or `req`.
|
17
|
+
|
13
18
|
## 2.4.6 (2020-06-29)
|
14
19
|
|
15
20
|
* Use basis 10 (decimal system) when casting a `String` to an `Integer`
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.4.
|
1
|
+
2.4.7
|
data/doc/Schemacop.html
CHANGED
@@ -111,8 +111,8 @@
|
|
111
111
|
</dt>
|
112
112
|
<dd><pre class="code"><span class='lbrace'>{</span>
|
113
113
|
<span class='const'>String</span> <span class='op'>=></span> <span class='lbrace'>{</span>
|
114
|
-
<span class='const'>Integer</span> <span class='op'>=></span> <span class='id identifier rubyid_proc'>proc</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_s'>s</span><span class='op'>|</span> <span class='const'>Integer</span><span class='lparen'>(</span><span class='id identifier rubyid_s'>s</span><span class='comma'>,</span> <span class='int'>10</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
115
|
-
<span class='const'>Float</span> <span class='op'>=></span> <span class='id identifier rubyid_proc'>proc</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_s'>s</span><span class='op'>|</span> <span class='const'>Float</span><span class='lparen'>(</span><span class='id identifier rubyid_s'>s</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
114
|
+
<span class='const'>Integer</span> <span class='op'>=></span> <span class='id identifier rubyid_proc'>proc</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_s'>s</span><span class='op'>|</span> <span class='id identifier rubyid_s'>s</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>?</span> <span class='kw'>nil</span> <span class='op'>:</span> <span class='const'>Integer</span><span class='lparen'>(</span><span class='id identifier rubyid_s'>s</span><span class='comma'>,</span> <span class='int'>10</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
115
|
+
<span class='const'>Float</span> <span class='op'>=></span> <span class='id identifier rubyid_proc'>proc</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_s'>s</span><span class='op'>|</span> <span class='id identifier rubyid_s'>s</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>?</span> <span class='kw'>nil</span> <span class='op'>:</span> <span class='const'>Float</span><span class='lparen'>(</span><span class='id identifier rubyid_s'>s</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
116
116
|
<span class='rbrace'>}</span><span class='comma'>,</span>
|
117
117
|
<span class='const'>Float</span> <span class='op'>=></span> <span class='lbrace'>{</span>
|
118
118
|
<span class='const'>Integer</span> <span class='op'>=></span> <span class='id identifier rubyid_proc'>proc</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span> <span class='const'>Integer</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
@@ -136,7 +136,7 @@
|
|
136
136
|
</div>
|
137
137
|
|
138
138
|
<div id="footer">
|
139
|
-
Generated on
|
139
|
+
Generated on Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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.
|
|
777
777
|
</div>
|
778
778
|
|
779
779
|
<div id="footer">
|
780
|
-
Generated on
|
780
|
+
Generated on Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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>
|
@@ -283,7 +283,7 @@
|
|
283
283
|
</div>
|
284
284
|
|
285
285
|
<div id="footer">
|
286
|
-
Generated on
|
286
|
+
Generated on Thu Jul 2 11:30:34 2020 by
|
287
287
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
288
288
|
0.9.20 (ruby-2.6.2).
|
289
289
|
</div>
|
@@ -148,7 +148,7 @@
|
|
148
148
|
</div>
|
149
149
|
|
150
150
|
<div id="footer">
|
151
|
-
Generated on
|
151
|
+
Generated on Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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.
|
|
602
602
|
</div>
|
603
603
|
|
604
604
|
<div id="footer">
|
605
|
-
Generated on
|
605
|
+
Generated on Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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.
|
|
689
689
|
</div>
|
690
690
|
|
691
691
|
<div id="footer">
|
692
|
-
Generated on
|
692
|
+
Generated on Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:34 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 Thu Jul 2 11:30:33 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
@@ -823,7 +823,7 @@ file
|
|
823
823
|
</div></div>
|
824
824
|
|
825
825
|
<div id="footer">
|
826
|
-
Generated on
|
826
|
+
Generated on Thu Jul 2 11:30:34 2020 by
|
827
827
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
828
828
|
0.9.20 (ruby-2.6.2).
|
829
829
|
</div>
|
data/doc/index.html
CHANGED
@@ -823,7 +823,7 @@ file
|
|
823
823
|
</div></div>
|
824
824
|
|
825
825
|
<div id="footer">
|
826
|
-
Generated on
|
826
|
+
Generated on Thu Jul 2 11:30:33 2020 by
|
827
827
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
828
828
|
0.9.20 (ruby-2.6.2).
|
829
829
|
</div>
|
@@ -102,7 +102,7 @@
|
|
102
102
|
</div>
|
103
103
|
|
104
104
|
<div id="footer">
|
105
|
-
Generated on
|
105
|
+
Generated on Thu Jul 2 11:30:34 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>
|
data/lib/schemacop.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Schemacop
|
2
2
|
DEFAULT_CASTERS = {
|
3
3
|
String => {
|
4
|
-
Integer => proc { |s| Integer(s, 10) },
|
5
|
-
Float => proc { |s| Float(s) }
|
4
|
+
Integer => proc { |s| s.blank? ? nil : Integer(s, 10) },
|
5
|
+
Float => proc { |s| s.blank? ? nil : Float(s) }
|
6
6
|
},
|
7
7
|
Float => {
|
8
8
|
Integer => proc { |f| Integer(f) }
|
@@ -15,6 +15,7 @@ end
|
|
15
15
|
|
16
16
|
require 'set'
|
17
17
|
require 'active_support/core_ext/class/attribute'
|
18
|
+
require 'active_support/core_ext/object/blank'
|
18
19
|
require 'active_support/hash_with_indifferent_access'
|
19
20
|
|
20
21
|
require 'schemacop/scoped_env'
|
data/schemacop.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: schemacop 2.4.
|
2
|
+
# stub: schemacop 2.4.7 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.7"
|
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-
|
11
|
+
s.date = "2020-07-02"
|
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/empty_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/casting_test.rb
CHANGED
@@ -96,5 +96,23 @@ module Schemacop
|
|
96
96
|
assert_equal 8, s.validate!('08')
|
97
97
|
assert_equal 11, s.validate!('011')
|
98
98
|
end
|
99
|
+
|
100
|
+
def test_string_to_nil_castings
|
101
|
+
s = Schema.new do
|
102
|
+
opt :int_field, :integer, cast: [String]
|
103
|
+
opt :float_field, :float, cast: [String]
|
104
|
+
end
|
105
|
+
|
106
|
+
expected_int = { int_field: nil }
|
107
|
+
expected_float = { float_field: nil }
|
108
|
+
|
109
|
+
assert_equal expected_int, s.validate!(int_field: nil)
|
110
|
+
assert_equal expected_int, s.validate!(int_field: "")
|
111
|
+
assert_equal expected_int, s.validate!(int_field: " ")
|
112
|
+
|
113
|
+
assert_equal expected_float, s.validate!(float_field: nil)
|
114
|
+
assert_equal expected_float, s.validate!(float_field: "")
|
115
|
+
assert_equal expected_float, s.validate!(float_field: " ")
|
116
|
+
end
|
99
117
|
end
|
100
118
|
end
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sitrox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|