compel 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/compel/contract.rb +2 -3
- data/lib/compel/version.rb +1 -1
- data/spec/compel/compel_spec.rb +24 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: babd567c6c66e9826606f628417eb16599a30f43
|
4
|
+
data.tar.gz: 3abbd9005a7aeb99146677491cd5a9d9b59add3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b326bc4046b7844f027a5cde2ed1316dfe32180a5b2a804a93b368221740f05f88cb43d1c9781080aa80ea00391845ac16f1602fc94c637d7e51bba9daee352f
|
7
|
+
data.tar.gz: 77f93f863cd71d5779d7e76d0d658c41f47ca9e0766fc38fbfd8ba08a1a390c946c75bd3621549cff20708711a6c24101c4e7f2ea04b7f0c34a7a0dec09d7dc1
|
data/lib/compel/contract.rb
CHANGED
@@ -26,9 +26,9 @@ module Compel
|
|
26
26
|
# build a new Compel::Contract form inner conditions
|
27
27
|
if (param.hash? && param.conditions?)
|
28
28
|
|
29
|
-
# If this param is required, build the Compel::Contract
|
29
|
+
# If this param is required, a value must be given to build the Compel::Contract
|
30
30
|
# otherwise, only build it if is given a value for the param
|
31
|
-
if param.required? || !param.value.nil?
|
31
|
+
if (param.required? && !param.value.nil?) || !param.value.nil?
|
32
32
|
contract = Contract.new(param.value, ¶m.conditions).validate
|
33
33
|
|
34
34
|
@errors.add(param.name, contract.errors)
|
@@ -44,7 +44,6 @@ module Compel
|
|
44
44
|
|
45
45
|
# If the param value has already been coerced from digging into child Hash
|
46
46
|
# use that value instead, so we don't lose the previous coerced values
|
47
|
-
|
48
47
|
coerced_value = Coercion.coerce! \
|
49
48
|
(@coerced_params[param.name].nil? ? param.value : @coerced_params[param.name]), param.type, param.options
|
50
49
|
|
data/lib/compel/version.rb
CHANGED
data/spec/compel/compel_spec.rb
CHANGED
@@ -204,7 +204,7 @@ describe Compel do
|
|
204
204
|
errors: {
|
205
205
|
address: {
|
206
206
|
line_one: ['is required'],
|
207
|
-
post_code: ['
|
207
|
+
post_code: ['is required']
|
208
208
|
}
|
209
209
|
}
|
210
210
|
})
|
@@ -304,6 +304,29 @@ describe Compel do
|
|
304
304
|
}
|
305
305
|
}
|
306
306
|
})
|
307
|
+
|
308
|
+
end
|
309
|
+
|
310
|
+
it 'should not compel 4' do
|
311
|
+
params = {
|
312
|
+
address: nil
|
313
|
+
}
|
314
|
+
|
315
|
+
expect(make_the_call(:run, params)).to eq \
|
316
|
+
Hashie::Mash.new({
|
317
|
+
errors: {
|
318
|
+
address: ['is required']
|
319
|
+
}
|
320
|
+
})
|
321
|
+
end
|
322
|
+
|
323
|
+
it 'should not compel 5' do
|
324
|
+
expect(make_the_call(:run, {})).to eq \
|
325
|
+
Hashie::Mash.new({
|
326
|
+
errors: {
|
327
|
+
address: ['is required']
|
328
|
+
}
|
329
|
+
})
|
307
330
|
end
|
308
331
|
|
309
332
|
end
|