getValidatedBody

Result<T, String> getValidatedBody<T>(

  1. Request req
)

Get validated body from request (use after validateBody middleware)

Implementation

Result<T, String> getValidatedBody<T>(Request req) {
  final value = req[_validatedBodyKey]?.dartify();
  return switch (value) {
    final T v => Success(v),
    _ => const Error(
      'No validated body found. Did you use validateBody middleware?',
    ),
  };
}