process method

  1. @override
dynamic process(
  1. Request request,
  2. ControllerMethodParam methodParam
)
override

Implementation

@override
process(Request request, ControllerMethodParam methodParam) {
  final body = request.body;
  if (body == null) {
    if (methodParam.optional) return null;
    throw RequestValidationError.body(
        EzValidator.globalLocale.required('body'));
  }

  final dtoInstance = methodParam.dto;
  if (dtoInstance != null) return dtoInstance..make(request);

  final type = methodParam.type;
  if (type != dynamic && body.runtimeType != type) {
    throw RequestValidationError.body(
        EzValidator.globalLocale.isTypeOf('${methodParam.type}', 'body'));
  }

  return body;
}