Skip to content

Commit ec1fe76

Browse files
author
Tim Vandecasteele
committed
Add nested parameters explanation to readme.
1 parent d021e22 commit ec1fe76

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

README.markdown

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ You can define validations and coercion options for your parameters using `param
220220
params do
221221
requires :id, type: Integer
222222
optional :name, type: String, regexp: /^[a-z]+$/
223+
224+
group :user do
225+
requires :first_name
226+
requires :last_name
227+
end
223228
end
224229
get ':id' do
225230
# params[:id] is an Integer
@@ -229,6 +234,9 @@ end
229234
When a type is specified an implicit validation is done after the coercion to ensure
230235
the output type is the one declared.
231236

237+
Parameters can be nested using `group`. In the above example, this means both
238+
`params[:user][:first_name]` and `params[:user][:last_name]` are required next to `params[:id]`.
239+
232240
### Namespace Validation and Coercion
233241
Namespaces allow parameter definitions and apply to every method within the namespace.
234242

0 commit comments

Comments
 (0)