README.md in weak_parameters-0.2.3 vs README.md in weak_parameters-0.3.0
- old
+ new
@@ -19,19 +19,20 @@
end
# WeakParameters provides `validates` class method to define validations.
class RecipesController < ApplicationController
validates :create do
- string :name, required: true, except: ["charlie", "dave"]
- integer :type, only: 1..3
+ string :name, required: true, except: ["charlie", "dave"], strong: true
+ integer :type, only: 1..3, strong: true
string :quantity do |value|
value =~ /\A\d+(?:\.\d+)g\z/
end
end
def create
- respond_with Recipe.create(params.slice(:name, :type))
+ # pass the only parameters with strong option. like strong parameters.
+ respond_with Recipe.create(permitted_params)
end
end
```
```ruby
@@ -62,9 +63,10 @@
### Available options
* required
* only
* except
* handler
+* strong
## Tips
WeakParameters.stats returns its validation metadata, and this is useful for auto-generating API documents.
With [autodoc](https://github.com/r7kamura/autodoc), you can auto-generate API documents with params information.