requireBool method
Requires a valid boolean environment variable identified by key.
Accepts 'true', '1', 'yes' (case-insensitive) as true,
and 'false', '0', 'no' as false.
Throws BloomEnvironmentException if missing, empty, or unparseable.
Implementation
bool requireBool(String key, {String? description}) {
final val = BloomEnv.getOrNull(key)?.trim();
if (val == null || val.isEmpty) {
final desc = description != null ? ' ($description)' : '';
final err = 'Missing required boolean environment variable "$key"$desc.';
_validationErrors.add(err);
throw BloomEnvironmentException(err, errors: [err]);
}
final lower = val.toLowerCase();
if (lower == 'true' || lower == '1' || lower == 'yes') return true;
if (lower == 'false' || lower == '0' || lower == 'no') return false;
final err = 'Environment variable "$key" is not a valid boolean: "$val".';
_validationErrors.add(err);
throw BloomEnvironmentException(err, errors: [err]);
}