requireString function

String requireString(
  1. JsonMap input,
  2. String key
)

Reads a string that must be present and non-blank.

Implementation

String requireString(JsonMap input, String key) {
  final value = readString(input, key);
  if (value == null || value.trim().isEmpty) {
    throw ToolFailure('`$key` is required.');
  }
  return value;
}