process method

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

Implementation

@override
process(Request request, ControllerMethodParam methodParam) {
  final paramName = name ?? methodParam.name;
  final value = request.headers[paramName] ?? methodParam.defaultValue;
  if (!methodParam.optional && value == null) {
    throw RequestValidationError.header(
        EzValidator.globalLocale.required(paramName));
  }

  final parsedValue = _parseValue(value, methodParam.type);
  if (parsedValue == null) {
    throw RequestValidationError.header(
        EzValidator.globalLocale.isTypeOf('${methodParam.type}', paramName));
  }
  return parsedValue;
}