weasel_diesel 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -0
- data/lib/params_verification.rb +3 -1
- data/lib/weasel_diesel/version.rb +1 -1
- data/spec/params_verification_spec.rb +10 -0
- metadata +4 -4
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,16 @@
|
|
3
3
|
All changes can be seen on GitHub and git tags are used to isolate each
|
4
4
|
release.
|
5
5
|
|
6
|
+
*1.2.1*:
|
7
|
+
|
8
|
+
* Modified the way an empty string param is cast/verified. If a param is
|
9
|
+
passed as an empty string but the param isn't specified as a string, the
|
10
|
+
param is nullified. So if you pass `{'id' => ''}`, and `id` is set to be
|
11
|
+
an integer param, the cast params will look like that: `{'id' => nil}`,
|
12
|
+
however if `name` is a string param and `{'name' => ''}` is passed, the
|
13
|
+
value won't be nullified.
|
14
|
+
|
15
|
+
|
6
16
|
**1.2.0**:
|
7
17
|
|
8
18
|
* All service urls are now stored with a prepended slash (if not defined
|
data/lib/params_verification.rb
CHANGED
@@ -165,7 +165,7 @@ module ParamsVerification
|
|
165
165
|
#
|
166
166
|
# @param [Object] param_value The value to validate and cast.
|
167
167
|
# @param [String] param_name The name of the param we are validating.
|
168
|
-
# @param [Symbol]
|
168
|
+
# @param [Symbol] rule_type The expected object type.
|
169
169
|
# @param [Hash] params The params that might need to be updated.
|
170
170
|
# @param [String, Symbol] namespace The optional namespace used to access the `param_value`
|
171
171
|
#
|
@@ -175,6 +175,8 @@ module ParamsVerification
|
|
175
175
|
def self.validate_and_cast_type(param_value, param_name, rule_type, params, namespace=nil)
|
176
176
|
# checks type & modifies params if needed
|
177
177
|
if rule_type && param_value
|
178
|
+
# nullify empty strings for any types other than string
|
179
|
+
param_value = nil if param_value == '' && rule_type != :string
|
178
180
|
verify_cast(param_name, param_value, rule_type)
|
179
181
|
param_value = type_cast_value(rule_type, param_value)
|
180
182
|
# update the params hash with the type cast value
|
@@ -187,4 +187,14 @@ describe ParamsVerification do
|
|
187
187
|
lambda{ ParamsVerification.validate!(params, @service.defined_params) }.should raise_exception(ParamsVerification::InvalidParamValue)
|
188
188
|
end
|
189
189
|
|
190
|
+
it "should allow optional null integer params" do
|
191
|
+
service = WeaselDiesel.new("spec")
|
192
|
+
service.params do |p|
|
193
|
+
p.integer :id, :optional => true, :null => true
|
194
|
+
end
|
195
|
+
params = {"id" => ""}
|
196
|
+
lambda{ ParamsVerification.validate!(params, service.defined_params) }.should_not raise_exception
|
197
|
+
params = {"id" => nil}
|
198
|
+
lambda{ ParamsVerification.validate!(params, service.defined_params) }.should_not raise_exception
|
199
|
+
end
|
190
200
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weasel_diesel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -146,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
segments:
|
148
148
|
- 0
|
149
|
-
hash:
|
149
|
+
hash: 1325572656893606813
|
150
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
151
|
none: false
|
152
152
|
requirements:
|
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
155
|
version: '0'
|
156
156
|
segments:
|
157
157
|
- 0
|
158
|
-
hash:
|
158
|
+
hash: 1325572656893606813
|
159
159
|
requirements: []
|
160
160
|
rubyforge_project: wsdsl
|
161
161
|
rubygems_version: 1.8.24
|