Documentation
    Preparing search index...

    Function TypedBody

    • Type safe body decorator.

      TypedBody is a decorator function getting application/json typed data from request body. Also, it validates the request body data type through typia using the declared TypeScript type.

      For reference, when the request body data is not following the promised type T, BadRequestException error (status code: 400) would be thrown. Successful assert and validate callbacks supply the decorated argument; clone validators can therefore return a copy without replacing the raw body.

      Type Parameters

      • T

      Parameters

      • Optionalvalidator: IRequestBodyValidator<T>

        Custom validator if required. Default is typia.validate()

      Returns ParameterDecorator

      Jeongho Nam - https://github.com/samchon

      contracts/common.md#principled-implementation An absent body with no content type is accepted only when the validator accepts undefined; any other body must be application/json. The checker returns explicitly tagged successful data or the existing validation error, so cloned values reach the argument while raw request.body retains its identity and errors retain their response priority.

      contracts/common.md#clear-and-simple-design One parameter decorator composes shared media/absence checks and tagged resolution. The shared internal runner owns descriptor selection and error translation; PlainBody uses the same successful-value protocol for its optional transformed text assertion, preserving raw text when no assertion exists and preserving its absent-input/media error priority.

      contracts/common.md#prohibited-implementation-shortcuts The validator is generated from the type by the transform; without it the decorator throws the configuration error unless the guard is turned off.

      contracts/common.md#meaningful-documentation The comment documents the decorator, the media type rule, and the validation modes.

      contracts/portability.md#os-neutral-implementation Parsed HTTP bodies and validation callbacks are independent of native filesystem and process representation.