requireUri method

Uri requireUri(
  1. String key, {
  2. String? description,
})

Requires a valid absolute URI environment variable identified by key.

Validates that the URI is parseable and contains a scheme (e.g. https://...). Throws BloomEnvironmentException if missing, empty, or invalid.

Implementation

Uri requireUri(String key, {String? description}) {
  final str = requireString(key, description: description);
  final parsed = Uri.tryParse(str);
  if (parsed == null || !parsed.hasScheme) {
    final err =
        'Environment variable "$key" is not a valid absolute URI: "$str".';
    _validationErrors.add(err);
    throw BloomEnvironmentException(err, errors: [err]);
  }
  return parsed;
}