README.md in decanter-0.8.2 vs README.md in decanter-0.9.0
- old
+ new
@@ -420,30 +420,56 @@
No Need for Strong Params
---
Since you are already defining your expected inputs in Decanter, you really don't need strong params anymore.
-In order to tell Decanter to ignore the params not defined in your Decanter, just add the ```strict``` flag to your Decanters:
+Note: starting with version 0.7.2, the default strict mode is ```:with_exception```. You can modify your default strict mode in your configuration file (see the "Configuration" section below).
+#### Mode: with_exception (default mode)
+
+To raise exceptions when parameters arrive in your Decanter that you didn't expect:
+
```ruby
class TripDecanter < Decanter::Base
- strict true
+ strict :with_exception
input :name
end
```
-Or to raise exceptions when parameters arrive in your Decanter that you didn't expect:
+#### Mode: strict
+In order to tell Decanter to ignore the params not defined in your Decanter, just add the ```strict``` flag to your Decanters:
+
```ruby
class TripDecanter < Decanter::Base
- strict :with_exception
+ strict true
input :name
end
```
-In addition, if you provide the option `:required` for an input in your decanter, an exception will be thrown if the parameters is nil or an empty string.
+#### Requiring Params
+
+If you provide the option `:required` for an input in your decanter, an exception will be thrown if the parameters is nil or an empty string.
+
+```ruby
+class TripDecanter < Decanter::Base
+ input :name, :string, required: true
+end
+```
+
+#### Ignoring Params
+
+If you anticipate your decanter will receive certain params that you simply want to ignore and therefore do not want Decanter to raise an exception, you can do so by calling the `ignore` method:
+
+```ruby
+class TripDecanter < Decanter::Base
+ ignore :created_at, :updated_at
+
+ input :name, :string
+end
+```
Configuration
---
You can generate a local copy of the default configuration with ```rails generate decanter:install```. This will create the initializer ```../config/initializers/decanter.rb```.