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
Recursively count hash values: if value is hash, recurse; else count as 1
validate_config('config.yml')
Configuration valid: 8 settings loaded
validate_config('config.yml')
Missing required field: database.port
validate_config('config.yml')
Invalid type for database.port: expected Integer, got String
Console output will appear here...
Are you sure?
You're making great progress