rack-param 0.1.0 → 0.1.1
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 -1
- data/lib/rack/param.rb +3 -3
- data/rack-param.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e233f217adb28e44d48871d58c6e656aa8d8e1e
|
4
|
+
data.tar.gz: f769cccbc58260148238ed32d7c0b71e5fbadfe9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39af897f8210bf83eaba39929f01f212078ca019ad861608cba6db1e4b726d4639cf644d6c1020c4127c25156c902a14a22a8a6ea7f1d79b5c6c407786c99c31
|
7
|
+
data.tar.gz: 74fbf160e046e0af706330d3a8912360b5a80c3ddf2dd5c671207e9c26ad4aec74f9c5b969ac94425eca1c9a84eb2e4b521b632eb5c508c9935e39c869ace4ff
|
data/CHANGELOG.md
CHANGED
@@ -9,4 +9,8 @@ v 0.1.0
|
|
9
9
|
- Complete rewrite
|
10
10
|
* Write tests
|
11
11
|
* Make rules more readable in `param.rb`
|
12
|
-
* `Rack::Request#params` now points to coerced and validated parameters
|
12
|
+
* `Rack::Request#params` now points to coerced and validated parameters
|
13
|
+
|
14
|
+
v 0.1.1
|
15
|
+
|
16
|
+
- Fix bug where invalid error message would be returned
|
data/lib/rack/param.rb
CHANGED
@@ -54,7 +54,7 @@ module Rack
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def validate param, value
|
57
|
-
return @message.sub("$",param.to_s).sub("#",value.to_s) unless @block.call(param,value)
|
57
|
+
return @message.sub("$", "`#{param.to_s}`").sub("#","`#{value.to_s}`") unless @block.call(param,value)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -107,7 +107,7 @@ module Rack
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
validate_error = opts.detect { |k,v| rules[k].validate
|
110
|
+
validate_error = opts.detect { |k,v| break rules[k].validate(@value, v) }
|
111
111
|
return validate_error unless validate_error.nil?
|
112
112
|
|
113
113
|
@value = @transform.to_proc.call @value if @transform
|
@@ -127,7 +127,7 @@ module Rack
|
|
127
127
|
@rules[:max_length] = Rule.rule("$ must be shorter than #.") { |p,v| p.length <= v }
|
128
128
|
@rules[:in] = Rule.rule("$ must be included in #.") { |p,v| v.include? p }
|
129
129
|
@rules[:contains] = Rule.rule("$ must include #") { |p,v| p.include? v }
|
130
|
-
@rules[:regex] = Rule.rule("$ failed validation.") { |p,v| v.match
|
130
|
+
@rules[:regex] = Rule.rule("$ failed validation.") { |p,v| v.match(p) rescue false }
|
131
131
|
@rules[:validator] = Rule.rule("$ failed validation.") { |p,v| v.call p }
|
132
132
|
end
|
133
133
|
@rules
|
data/rack-param.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "rack-param"
|
7
|
-
spec.version = "0.1.
|
7
|
+
spec.version = "0.1.1"
|
8
8
|
spec.authors = ["Nathaniel Symer"]
|
9
9
|
spec.email = ["nate@natesymer.com"]
|
10
10
|
spec.summary = "Sane parameter validation for Rack::Request."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-param
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathaniel Symer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|