field<T> method

Result<T, Rejection> field<T>(
  1. String name
)

Reads part name as text, coerced to T.

Implementation

Result<T, Rejection> field<T>(String name) {
  final part = parts[name];
  if (part == null) {
    if (null is T) return Ok(null as T);
    return Err(Rejection.badRequest('multipart part "$name" is required'));
  }
  return coerce<T>(part.asText, source: 'multipart part "$name"');
}