Production applications rely on configuration files to manage environment-specific settings like database connections, API keys, and feature flags. This drill teaches you to parse YAML config files, validate required fields, check data types, and provide helpful error messages when configuration is invalid. You'll learn YAML parsing, hash validation, type checking, and error handling—essential skills for building reliable Ruby applications and tools.
YAML.load_file(file) parses YAML and returns a hash
Use hash.dig('key1', 'key2') to safely access nested values
Check if value is nil to detect missing fields
value.is_a?(Integer) checks if value is an integer
[TrueClass, FalseClass].include?(value.class) checks for boolean
Split 'database.port' on '.' to get array of keys for .dig
validate_config('config.yml')
Configuration valid: 13 settings loaded
result = validate_config('config.yml')
puts result
Configuration valid: 13 settings loaded true
validate_config('config.yml')
puts 'Validation complete'
Configuration valid: 13 settings loaded Validation complete
Console output will appear here...
Are you sure?
You're making great progress
Become a Ruby Pro
1,600+ problems to master every concept