README.md in config-1.4.0 vs README.md in config-1.5.0
- old
+ new
@@ -43,11 +43,11 @@
config/settings/development.yml
config/settings/production.yml
config/settings/test.yml
You can now edit them to adjust to your needs.
-a
+
### Installing on Padrino
Add the gem to your `Gemfile` and run `bundle install` to install it. Then edit `app.rb` and register `Config`
```ruby
@@ -273,10 +273,34 @@
* `overwrite_arrays` - overwrite arrays found in previously loaded settings file. Default: `true`
* `knockout_prefix` - ability to remove elements of the array set in earlier loaded settings file. Makes sense only when `overwrite_arrays = false`, otherwise array settings would be overwritten by default. Default: `nil`
Check [Deep Merge](https://github.com/danielsdeleo/deep_merge) for more details.
+### Validation
+
+With Ruby 2.1 or newer, you can optionally define a schema to validate presence (and type) of specific config values:
+
+```ruby
+Config.setup do |config|
+ # ...
+ config.schema do
+ required(:youtube).schema do
+ required(:api_key).filled
+ end
+ end
+end
+```
+
+The above example demonstrates how to ensure that the configuration has the `youtube` structure
+with the `api_key` field filled.
+
+If you define a schema it will automatically be used to validate your config. If validation fails it will
+raise a `Config::Validation::Error` containing a nice message with information about all the mismatches
+between the schema and your config.
+
+Check [dry-validation](https://github.com/dry-rb/dry-validation) for more details.
+
### Environment variables
See section below for more details.
## Working with environment variables
@@ -332,10 +356,10 @@
And the following configuration:
```ruby
Config.setup do |config|
config.use_env = true
- config.env_prefix = 'Settings'
+ config.env_prefix = 'SETTINGS'
config.env_separator = '__'
config.env_converter = :downcase
config.env_parse_values = true
end
```