grape 0.17.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grape might be problematic. Click here for more details.

Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -3
  3. data/Dangerfile +1 -80
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +69 -51
  6. data/README.md +42 -1
  7. data/UPGRADING.md +2 -2
  8. data/grape.gemspec +1 -1
  9. data/lib/grape/api.rb +5 -15
  10. data/lib/grape/cookies.rb +1 -1
  11. data/lib/grape/dsl/inside_route.rb +2 -3
  12. data/lib/grape/dsl/request_response.rb +1 -1
  13. data/lib/grape/endpoint.rb +19 -7
  14. data/lib/grape/error_formatter.rb +2 -2
  15. data/lib/grape/exceptions/base.rb +18 -18
  16. data/lib/grape/exceptions/validation.rb +6 -7
  17. data/lib/grape/exceptions/validation_errors.rb +5 -5
  18. data/lib/grape/formatter.rb +2 -2
  19. data/lib/grape/locale/en.yml +1 -0
  20. data/lib/grape/middleware/auth/base.rb +2 -2
  21. data/lib/grape/middleware/base.rb +2 -2
  22. data/lib/grape/middleware/error.rb +1 -1
  23. data/lib/grape/middleware/stack.rb +1 -1
  24. data/lib/grape/middleware/versioner/header.rb +1 -1
  25. data/lib/grape/namespace.rb +1 -1
  26. data/lib/grape/parser.rb +2 -2
  27. data/lib/grape/presenters/presenter.rb +1 -1
  28. data/lib/grape/router.rb +6 -6
  29. data/lib/grape/router/pattern.rb +7 -7
  30. data/lib/grape/router/route.rb +3 -3
  31. data/lib/grape/util/env.rb +1 -1
  32. data/lib/grape/validations/params_scope.rb +15 -7
  33. data/lib/grape/validations/validators/allow_blank.rb +0 -13
  34. data/lib/grape/validations/validators/base.rb +8 -1
  35. data/lib/grape/validations/validators/default.rb +1 -3
  36. data/lib/grape/validations/validators/presence.rb +0 -5
  37. data/lib/grape/validations/validators/values.rb +17 -3
  38. data/lib/grape/version.rb +1 -1
  39. data/pkg/grape-0.18.0.gem +0 -0
  40. data/spec/grape/api_spec.rb +41 -0
  41. data/spec/grape/exceptions/validation_spec.rb +1 -1
  42. data/spec/grape/middleware/stack_spec.rb +20 -0
  43. data/spec/grape/validations/params_scope_spec.rb +190 -58
  44. data/spec/grape/validations/validators/allow_blank_spec.rb +22 -7
  45. data/spec/grape/validations/validators/coerce_spec.rb +6 -6
  46. data/spec/grape/validations/validators/values_spec.rb +146 -0
  47. data/spec/grape/validations_spec.rb +28 -0
  48. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19ace46ada09b1ab69918bf173940735acde0bbe
4
- data.tar.gz: 58f1a9cc4503974439dc28d496ecaab1668d0479
3
+ metadata.gz: a10ed4eece4262170f1bdd034e27829f5da0976c
4
+ data.tar.gz: 71ede66f37c08766ad1c978f0bbc42cb7ecc5ea9
5
5
  SHA512:
6
- metadata.gz: ead945737e0a4e6acf57803f1a86c19c43b999ea58c71cd7a07a8dc30e826e25515017ccf60714992c7a2a0e66a0f58789bcbff549bb65c92bc8fef4d06c762d
7
- data.tar.gz: 6d509b5dc49fd2f083cdb5a97e70fa17a43ad5bb6f282afa3e7ce23bd0fa73f85cf5417d6ed703e1747111b5ab3491376748a73d007df9387d9c2f5ace3ac553
6
+ metadata.gz: ab6b58872ecdd19c14ee84980de47e7984edabeb95ea4de0491ee72b5c2eff6aa9f18e4c961751c338638c77f90b86fe21abb58e71e10ae574fce308b14305ac
7
+ data.tar.gz: e101543915e945736dbeb2f92f198941197b5b9abd0613961af6a955e9782d9e70ea522a1e27aa93799bd227c3db7837fd35a66dec412dc63d1633f32cca3193
data/CHANGELOG.md CHANGED
@@ -1,14 +1,33 @@
1
+ 0.18.0 (10/7/2016)
2
+ ==================
3
+
4
+ #### Features
5
+
6
+ * [#1480](https://github.com/ruby-grape/grape/pull/1480): Use the ruby-grape-danger gem for PR linting - [@dblock](https://github.com/dblock).
7
+ * [#1486](https://github.com/ruby-grape/grape/pull/1486): Implemented except in values validator - [@jonmchan](https://github.com/jonmchan).
8
+ * [#1470](https://github.com/ruby-grape/grape/pull/1470): Drop support for ruby-2.0 - [@namusyaka](https://github.com/namusyaka).
9
+ * [#1490](https://github.com/ruby-grape/grape/pull/1490): Switch to Ruby-2.x+ syntax - [@namusyaka](https://github.com/namusyaka).
10
+ * [#1499](https://github.com/ruby-grape/grape/pull/1499): Support fail_fast param validation option - [@dgasper](https://github.com/dgasper).
11
+
12
+ #### Fixes
13
+
14
+ * [#1498](https://github.com/ruby-grape/grape/pull/1498): Skip validations in inactive given blocks - [@jlfaber](https://github.com/jlfaber).
15
+ * [#1479](https://github.com/ruby-grape/grape/pull/1479): Support inserting middleware before/after anonymous classes in the middleware stack - [@rosa](https://github.com/rosa).
16
+ * [#1488](https://github.com/ruby-grape/grape/pull/1488): Ensure calling before filters when receiving OPTIONS request - [@namusyaka](https://github.com/namusyaka), [@jlfaber](https://github.com/jlfaber).
17
+ * [#1493](https://github.com/ruby-grape/grape/pull/1493): Coercion and lambda fails params validation - [@jonmchan](https://github.com/jonmchan).
18
+
1
19
  0.17.0 (7/29/2016)
2
20
  ==================
3
21
 
4
22
  #### Features
5
23
 
6
24
  * [#1393](https://github.com/ruby-grape/grape/pull/1393): Middleware can be inserted before or after default Grape middleware - [@ridiculous](https://github.com/ridiculous).
7
- * [#1390](https://github.com/ruby-grape/grape/pull/1390): Allow inserting middleware at arbitrary points in the middleware stack - [@Rosa](https://github.com/Rosa).
25
+ * [#1390](https://github.com/ruby-grape/grape/pull/1390): Allow inserting middleware at arbitrary points in the middleware stack - [@rosa](https://github.com/rosa).
8
26
  * [#1366](https://github.com/ruby-grape/grape/pull/1366): Store `message_key` on `Grape::Exceptions::Validation` - [@mkou](https://github.com/mkou).
9
27
  * [#1398](https://github.com/ruby-grape/grape/pull/1398): Add `rescue_from :grape_exceptions` - allow Grape to use the built-in `Grape::Exception` handing and use `rescue :all` behavior for everything else - [@mmclead](https://github.com/mmclead).
10
28
  * [#1443](https://github.com/ruby-grape/grape/pull/1443): Extend `given` to receive a `Proc` - [@glaucocustodio](https://github.com/glaucocustodio).
11
29
  * [#1455](https://github.com/ruby-grape/grape/pull/1455): Add an automated PR linter - [@orta](https://github.com/orta).
30
+ * Your contribution here.
12
31
 
13
32
  #### Fixes
14
33
 
@@ -311,7 +330,7 @@
311
330
 
312
331
  #### Features
313
332
 
314
- * Grape is no longer tested against Ruby 1.8.7.
333
+ * Grape is no longer tested against Ruby 1.8.7 - [@dblock](https://github.com/dblock).
315
334
  * [#442](https://github.com/ruby-grape/grape/issues/442): Enable incrementally building on top of a previous API version - [@dblock](https://github.com/dblock).
316
335
  * [#442](https://github.com/ruby-grape/grape/issues/442): API `version` can now take an array of multiple versions - [@dblock](https://github.com/dblock).
317
336
  * [#444](https://github.com/ruby-grape/grape/issues/444): Added `:en` as fallback locale for I18n - [@aew](https://github.com/aew).
@@ -460,7 +479,7 @@
460
479
  * [#204](https://github.com/ruby-grape/grape/pull/204): Added ability to declare shared `params` at `namespace` level - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
461
480
  * [#234](https://github.com/ruby-grape/grape/pull/234): Added a DSL for creating entities via mixin - [@mbleigh](https://github.com/mbleigh).
462
481
  * [#240](https://github.com/ruby-grape/grape/pull/240): Define API response format from a query string `format` parameter, if specified - [@neetiraj](https://github.com/neetiraj).
463
- * Adds Endpoint#declared to easily filter out unexpected params. - [@mbleigh](https://github.com/mbleigh)
482
+ * Adds Endpoint#declared to easily filter out unexpected params - [@mbleigh](https://github.com/mbleigh).
464
483
 
465
484
  #### Fixes
466
485
 
data/Dangerfile CHANGED
@@ -1,80 +1 @@
1
- # --------------------------------------------------------------------------------------------------------------------
2
- # Has any changes happened inside the actual library code?
3
- # --------------------------------------------------------------------------------------------------------------------
4
- has_app_changes = !git.modified_files.grep(/lib/).empty?
5
- has_spec_changes = !git.modified_files.grep(/spec/).empty?
6
-
7
- # --------------------------------------------------------------------------------------------------------------------
8
- # You've made changes to lib, but didn't write any tests?
9
- # --------------------------------------------------------------------------------------------------------------------
10
- if has_app_changes && !has_spec_changes
11
- raise("There're library changes, but not tests. That's OK as long as you're refactoring existing code.", sticky: false)
12
- end
13
-
14
- # --------------------------------------------------------------------------------------------------------------------
15
- # You've made changes to specs, but no library code has changed?
16
- # --------------------------------------------------------------------------------------------------------------------
17
- if !has_app_changes && has_spec_changes
18
- message('We really appreciate pull requests that demonstrate issues, even without a fix. That said, the next step is to try and fix the failing tests!', sticky: false)
19
- end
20
-
21
- # --------------------------------------------------------------------------------------------------------------------
22
- # Have you updated CHANGELOG.md?
23
- # --------------------------------------------------------------------------------------------------------------------
24
- if !git.modified_files.include?('CHANGELOG.md') && has_app_changes
25
- pr_number = github.pr_json['number']
26
- markdown <<-MARKDOWN
27
- Here's an example of a CHANGELOG.md entry:
28
-
29
- ```markdown
30
- * [##{pr_number}](https://github.com/ruby-grape/grape/pull/#{pr_number}): #{github.pr_title} - [@#{github.pr_author}](https://github.com/#{github.pr_author}).
31
- ```
32
- MARKDOWN
33
- raise('Please update CHANGELOG.md.', sticky: false)
34
- end
35
-
36
- # --------------------------------------------------------------------------------------------------------------------
37
- # Is the CHANGELOG.md format correct?
38
- # --------------------------------------------------------------------------------------------------------------------
39
-
40
- your_contribution_here = false
41
- releases = 0
42
- errors = 0
43
- File.open('CHANGELOG.md').each_line do |line|
44
- # only look at the top releases, we entered a lot of changes without a PR before
45
- if line == "==================\n"
46
- releases += 1
47
- break if releases == 5
48
- end
49
- # ignore lines that aren't changes
50
- next unless line[0] == '*'
51
- # notice your contribution here
52
- if line == "* Your contribution here.\n"
53
- your_contribution_here = true
54
- next
55
- end
56
- # match the PR format
57
- next if line =~ %r{^\*\s\[\#\d+\]\(https:\/\/github\.com\/.*\d+\)\: [\`[:upper:]].* \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\)\.$}
58
- errors += 1
59
- markdown <<-MARKDOWN
60
- ```markdown
61
- #{line}```
62
- MARKDOWN
63
- end
64
-
65
- raise("One of the lines below found in CHANGELOG.md doesn't match the expected format. Please make it look like the other lines, pay attention to periods and spaces.", sticky: false) if errors > 0
66
- raise('Please put back the `* Your contribution here.` line into CHANGELOG.md.', sticky: false) unless your_contribution_here
67
-
68
- # --------------------------------------------------------------------------------------------------------------------
69
- # Don't let testing shortcuts get into master by accident,
70
- # ensuring that we don't get green builds based on a subset of tests.
71
- # --------------------------------------------------------------------------------------------------------------------
72
-
73
- (git.modified_files + git.added_files - %w(Dangerfile)).each do |file|
74
- next unless File.file?(file)
75
- contents = File.read(file)
76
- if file.start_with?('spec')
77
- raise("`xit` or `fit` left in tests (#{file})") if contents =~ /^\w*[xf]it/
78
- raise("`fdescribe` left in tests (#{file})") if contents =~ /^\w*fdescribe/
79
- end
80
- end
1
+ danger.import_dangerfile(gem: 'ruby-grape-danger')
data/Gemfile CHANGED
@@ -28,5 +28,5 @@ group :test do
28
28
  gem 'cookiejar'
29
29
  gem 'rack-jsonp', require: 'rack/jsonp'
30
30
  gem 'mime-types', '< 3.0'
31
- gem 'danger', '~> 2.0'
31
+ gem 'ruby-grape-danger', '~> 0.1.0', require: false
32
32
  end
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape (0.17.0)
4
+ grape (0.18.0)
5
5
  activesupport
6
6
  builder
7
7
  hashie (>= 2.1.0)
8
8
  multi_json (>= 1.3.2)
9
9
  multi_xml (>= 0.5.2)
10
- mustermann19 (~> 0.4.3)
10
+ mustermann-grape (~> 0.4.0)
11
11
  rack (>= 1.3.0)
12
12
  rack-accept
13
13
  virtus (>= 1.0.0)
@@ -15,26 +15,25 @@ PATH
15
15
  GEM
16
16
  remote: https://rubygems.org/
17
17
  specs:
18
- activesupport (4.2.6)
18
+ activesupport (5.0.0.1)
19
+ concurrent-ruby (~> 1.0, >= 1.0.2)
19
20
  i18n (~> 0.7)
20
- json (~> 1.7, >= 1.7.7)
21
21
  minitest (~> 5.1)
22
- thread_safe (~> 0.3, >= 0.3.4)
23
22
  tzinfo (~> 1.1)
24
23
  addressable (2.4.0)
25
24
  appraisal (2.1.0)
26
25
  bundler
27
26
  rake
28
27
  thor (>= 0.14.0)
29
- ast (2.2.0)
28
+ ast (2.3.0)
30
29
  axiom-types (0.1.1)
31
30
  descendants_tracker (~> 0.0.4)
32
31
  ice_nine (~> 0.11.0)
33
32
  thread_safe (~> 0.3, >= 0.3.1)
34
- benchmark-ips (2.6.1)
33
+ benchmark-ips (2.7.2)
35
34
  builder (3.2.2)
36
35
  claide (1.0.0)
37
- claide-plugins (0.9.1)
36
+ claide-plugins (0.9.2)
38
37
  cork
39
38
  nap
40
39
  open4 (~> 1.3)
@@ -42,38 +41,46 @@ GEM
42
41
  coercible (1.0.0)
43
42
  descendants_tracker (~> 0.0.1)
44
43
  colored (1.2)
44
+ concurrent-ruby (1.0.2)
45
45
  cookiejar (0.3.3)
46
- cork (0.1.0)
46
+ cork (0.2.0)
47
47
  colored (~> 1.2)
48
- danger (2.0.1)
48
+ danger (3.2.2)
49
49
  claide (~> 1.0)
50
50
  claide-plugins (> 0.9.0)
51
51
  colored (~> 1.2)
52
52
  cork (~> 0.1)
53
- faraday (~> 0)
53
+ faraday (~> 0.9)
54
54
  faraday-http-cache (~> 1.0)
55
55
  git (~> 1)
56
+ gitlab (~> 3.7.0)
57
+ kramdown (~> 1.5)
56
58
  octokit (~> 4.2)
57
- redcarpet (~> 3.3)
58
59
  terminal-table (~> 1)
60
+ danger-changelog (0.1.0)
61
+ danger-plugin-api (~> 1.0)
62
+ danger-plugin-api (1.0.0)
63
+ danger (> 2.0)
59
64
  descendants_tracker (0.0.4)
60
65
  thread_safe (~> 0.3, >= 0.3.1)
61
66
  diff-lcs (1.2.5)
62
- enumerable-lazy (0.0.1)
63
67
  equalizer (0.0.11)
64
68
  faraday (0.9.2)
65
69
  multipart-post (>= 1.2, < 3)
66
- faraday-http-cache (1.3.0)
70
+ faraday-http-cache (1.3.1)
67
71
  faraday (~> 0.8)
68
- ffi (1.9.10)
72
+ ffi (1.9.14)
69
73
  formatador (0.2.5)
70
74
  git (1.3.0)
75
+ gitlab (3.7.0)
76
+ httparty (~> 0.13.0)
77
+ terminal-table
71
78
  grape-entity (0.5.0)
72
79
  activesupport
73
80
  multi_json (>= 1.3.2)
74
- guard (2.13.0)
81
+ guard (2.14.0)
75
82
  formatador (>= 0.2.4)
76
- listen (>= 2.7, <= 4.0)
83
+ listen (>= 2.7, < 4.0)
77
84
  lumberjack (~> 1.0)
78
85
  nenv (~> 0.1)
79
86
  notiffany (~> 0.0)
@@ -81,47 +88,53 @@ GEM
81
88
  shellany (~> 0.0)
82
89
  thor (>= 0.18.1)
83
90
  guard-compat (1.2.1)
84
- guard-rspec (4.6.5)
91
+ guard-rspec (4.7.3)
85
92
  guard (~> 2.1)
86
93
  guard-compat (~> 1.1)
87
94
  rspec (>= 2.99.0, < 4.0)
88
95
  guard-rubocop (1.2.0)
89
96
  guard (~> 2.0)
90
97
  rubocop (~> 0.20)
91
- hashie (3.4.4)
98
+ hashie (3.4.6)
99
+ httparty (0.13.7)
100
+ json (~> 1.8)
101
+ multi_xml (>= 0.5.2)
92
102
  i18n (0.7.0)
93
103
  ice_nine (0.11.2)
94
104
  json (1.8.3)
95
- listen (3.1.2)
96
- rb-fsevent (>= 0.9.3)
97
- rb-inotify (>= 0.9.7)
98
- ruby_dep (~> 1.1)
105
+ kramdown (1.12.0)
106
+ listen (3.1.5)
107
+ rb-fsevent (~> 0.9, >= 0.9.4)
108
+ rb-inotify (~> 0.9, >= 0.9.7)
109
+ ruby_dep (~> 1.2)
99
110
  lumberjack (1.0.10)
100
111
  maruku (0.7.2)
101
112
  method_source (0.8.2)
102
- mime-types (2.99.1)
103
- minitest (5.8.4)
104
- multi_json (1.11.3)
113
+ mime-types (2.99.3)
114
+ minitest (5.9.1)
115
+ multi_json (1.12.1)
105
116
  multi_xml (0.5.5)
106
117
  multipart-post (2.0.0)
107
- mustermann19 (0.4.4)
108
- enumerable-lazy
118
+ mustermann (0.4.0)
119
+ tool (~> 0.2)
120
+ mustermann-grape (0.4.0)
121
+ mustermann (= 0.4.0)
109
122
  nap (1.1.0)
110
123
  nenv (0.3.0)
111
- notiffany (0.0.8)
124
+ notiffany (0.1.1)
112
125
  nenv (~> 0.1)
113
126
  shellany (~> 0.0)
114
127
  octokit (4.3.0)
115
128
  sawyer (~> 0.7.0, >= 0.5.3)
116
129
  open4 (1.3.4)
117
- parser (2.3.1.0)
130
+ parser (2.3.1.4)
118
131
  ast (~> 2.2)
119
132
  powerpack (0.1.1)
120
- pry (0.10.3)
133
+ pry (0.10.4)
121
134
  coderay (~> 1.1.0)
122
135
  method_source (~> 0.8.1)
123
136
  slop (~> 3.4)
124
- rack (1.6.4)
137
+ rack (2.0.1)
125
138
  rack-accept (0.4.5)
126
139
  rack (>= 0.4)
127
140
  rack-jsonp (1.3.1)
@@ -129,49 +142,54 @@ GEM
129
142
  rack-test (0.6.3)
130
143
  rack (>= 1.0)
131
144
  rainbow (2.1.0)
132
- rake (11.1.2)
145
+ rake (11.3.0)
133
146
  rb-fsevent (0.9.7)
134
147
  rb-inotify (0.9.7)
135
148
  ffi (>= 0.5.0)
136
149
  redcarpet (3.3.4)
137
- rspec (3.4.0)
138
- rspec-core (~> 3.4.0)
139
- rspec-expectations (~> 3.4.0)
140
- rspec-mocks (~> 3.4.0)
141
- rspec-core (3.4.4)
142
- rspec-support (~> 3.4.0)
143
- rspec-expectations (3.4.0)
150
+ rspec (3.5.0)
151
+ rspec-core (~> 3.5.0)
152
+ rspec-expectations (~> 3.5.0)
153
+ rspec-mocks (~> 3.5.0)
154
+ rspec-core (3.5.4)
155
+ rspec-support (~> 3.5.0)
156
+ rspec-expectations (3.5.0)
144
157
  diff-lcs (>= 1.2.0, < 2.0)
145
- rspec-support (~> 3.4.0)
146
- rspec-mocks (3.4.1)
158
+ rspec-support (~> 3.5.0)
159
+ rspec-mocks (3.5.0)
147
160
  diff-lcs (>= 1.2.0, < 2.0)
148
- rspec-support (~> 3.4.0)
149
- rspec-support (3.4.1)
161
+ rspec-support (~> 3.5.0)
162
+ rspec-support (3.5.0)
150
163
  rubocop (0.39.0)
151
164
  parser (>= 2.3.0.7, < 3.0)
152
165
  powerpack (~> 0.1)
153
166
  rainbow (>= 1.99.1, < 3.0)
154
167
  ruby-progressbar (~> 1.7)
155
168
  unicode-display_width (~> 1.0, >= 1.0.1)
156
- ruby-progressbar (1.8.0)
157
- ruby_dep (1.1.0)
169
+ ruby-grape-danger (0.1.0)
170
+ danger (~> 3.2.0)
171
+ danger-changelog (~> 0.1.0)
172
+ ruby-progressbar (1.8.1)
173
+ ruby_dep (1.4.0)
158
174
  sawyer (0.7.0)
159
175
  addressable (>= 2.3.5, < 2.5)
160
176
  faraday (~> 0.8, < 0.10)
161
177
  shellany (0.0.1)
162
178
  slop (3.6.0)
163
- terminal-table (1.6.0)
179
+ terminal-table (1.7.3)
180
+ unicode-display_width (~> 1.1.1)
164
181
  thor (0.19.1)
165
182
  thread_safe (0.3.5)
183
+ tool (0.2.3)
166
184
  tzinfo (1.2.2)
167
185
  thread_safe (~> 0.1)
168
- unicode-display_width (1.0.5)
186
+ unicode-display_width (1.1.1)
169
187
  virtus (1.0.5)
170
188
  axiom-types (~> 0.1)
171
189
  coercible (~> 1.0)
172
190
  descendants_tracker (~> 0.0, >= 0.0.3)
173
191
  equalizer (~> 0.0, >= 0.0.9)
174
- yard (0.8.7.6)
192
+ yard (0.9.5)
175
193
 
176
194
  PLATFORMS
177
195
  ruby
@@ -181,7 +199,6 @@ DEPENDENCIES
181
199
  benchmark-ips
182
200
  bundler
183
201
  cookiejar
184
- danger (~> 2.0)
185
202
  grape!
186
203
  grape-entity (= 0.5.0)
187
204
  guard
@@ -195,7 +212,8 @@ DEPENDENCIES
195
212
  redcarpet
196
213
  rspec (~> 3.0)
197
214
  rubocop (= 0.39.0)
215
+ ruby-grape-danger (~> 0.1.0)
198
216
  yard
199
217
 
200
218
  BUNDLED WITH
201
- 1.12.1
219
+ 1.12.5
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  [![Dependency Status](https://gemnasium.com/ruby-grape/grape.svg)](https://gemnasium.com/ruby-grape/grape)
6
6
  [![Code Climate](https://codeclimate.com/github/ruby-grape/grape.svg)](https://codeclimate.com/github/ruby-grape/grape)
7
7
  [![Inline docs](http://inch-ci.org/github/ruby-grape/grape.svg)](http://inch-ci.org/github/ruby-grape/grape)
8
+ [![git.legal](https://git.legal/projects/1364/badge.svg "Number of libraries approved")](https://git.legal/projects/1364)
8
9
  [![Join the chat at https://gitter.im/ruby-grape/grape](https://badges.gitter.im/ruby-grape/grape.svg)](https://gitter.im/ruby-grape/grape?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
9
10
 
10
11
  ## Table of Contents
@@ -1063,6 +1064,26 @@ params do
1063
1064
  end
1064
1065
  ```
1065
1066
 
1067
+ The values validator can also validate that the value is explicitly not within a specific
1068
+ set of values by passing ```except```. ```except``` accepts the same types of parameters as
1069
+ values (Procs, ranges, etc.).
1070
+
1071
+ ```ruby
1072
+ params do
1073
+ requires :browsers, values: { except: [ 'ie6', 'ie7', 'ie8' ] }
1074
+ end
1075
+ ```
1076
+
1077
+ Values and except can be combined to define a range of accepted values while not allowing
1078
+ certain values within the set. Custom error messages can be defined for both when the parameter
1079
+ passed falls within the ```except``` list or when it falls entirely outside the ```value``` list.
1080
+
1081
+ ```ruby
1082
+ params do
1083
+ requires :number, type: Integer, values: { value: 1..20 except: [4,13], except_message: 'includes unsafe numbers', message: 'is outside the range of numbers allowed' }
1084
+ end
1085
+ ```
1086
+
1066
1087
  #### `regexp`
1067
1088
 
1068
1089
  Parameters can be restricted to match a specific regular expression with the `:regexp` option. If the value
@@ -1333,6 +1354,25 @@ subject.rescue_from Grape::Exceptions::ValidationErrors do |e|
1333
1354
  end
1334
1355
  ```
1335
1356
 
1357
+ Grape returns all validation and coercion errors found by default.
1358
+ To skip all subsequent validation checks when a specific param is found invalid, use `fail_fast: true`.
1359
+
1360
+ The following example will not check if `:wine` is present unless it finds `:beer`.
1361
+ ```ruby
1362
+ params do
1363
+ required :beer, fail_fast: true
1364
+ required :wine
1365
+ end
1366
+ ```
1367
+ The result of empty params would be a single `Grape::Exceptions::ValidationErrors` error.
1368
+
1369
+ Similarly, no regular expression test will be performed if `:blah` is blank in the following example.
1370
+ ```ruby
1371
+ params do
1372
+ required :blah, allow_blank: false, regexp: /blah/, fail_fast: true
1373
+ end
1374
+ ```
1375
+
1336
1376
  ### I18n
1337
1377
 
1338
1378
  Grape supports I18n for parameter-related error messages, but will fallback to English if
@@ -1866,7 +1906,7 @@ end
1866
1906
  ```
1867
1907
 
1868
1908
  Grape can also rescue from all exceptions and still use the built-in exception handing.
1869
- This will give the same behavior as `rescue_from :all` with the addition that Grape will use the exception handling defined by all Exception classes that inherit Grape::Exceptions::Base.
1909
+ This will give the same behavior as `rescue_from :all` with the addition that Grape will use the exception handling defined by all Exception classes that inherit `Grape::Exceptions::Base`.
1870
1910
 
1871
1911
  The intent of this setting is to provide a simple way to cover the most common exceptions and return any unexpected exceptions in the API format.
1872
1912
 
@@ -3214,6 +3254,7 @@ Grape integrates with following third-party tools:
3214
3254
  * **New Relic** - [built-in support](https://docs.newrelic.com/docs/agents/ruby-agent/frameworks/grape-instrumentation) from v3.10.0 of the official [newrelic_rpm](https://github.com/newrelic/rpm) gem, also [newrelic-grape](https://github.com/xinminlabs/newrelic-grape) gem
3215
3255
  * **Librato Metrics** - [grape-librato](https://github.com/seanmoon/grape-librato) gem
3216
3256
  * **[Skylight](https://www.skylight.io/)** - [skylight](https://github.com/skylightio/skylight-ruby) gem, [documentation](https://docs.skylight.io/grape/)
3257
+ * **[AppSignal](https://www.appsignal.com)** - [appsignal-ruby](https://github.com/appsignal/appsignal-ruby) gem, [documentation](http://docs.appsignal.com/getting-started/supported-frameworks.html#grape)
3217
3258
 
3218
3259
  ## Contributing to Grape
3219
3260