Skip to content

Commit

Permalink
Add nested parameters explanation to readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Vandecasteele committed Sep 5, 2012
1 parent d021e22 commit ec1fe76
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ You can define validations and coercion options for your parameters using `param
params do
requires :id, type: Integer
optional :name, type: String, regexp: /^[a-z]+$/

group :user do
requires :first_name
requires :last_name
end
end
get ':id' do
# params[:id] is an Integer
Expand All @@ -229,6 +234,9 @@ end
When a type is specified an implicit validation is done after the coercion to ensure
the output type is the one declared.

Parameters can be nested using `group`. In the above example, this means both
`params[:user][:first_name]` and `params[:user][:last_name]` are required next to `params[:id]`.

### Namespace Validation and Coercion
Namespaces allow parameter definitions and apply to every method within the namespace.

Expand Down

0 comments on commit ec1fe76

Please sign in to comment.