Documentation
    Preparing search index...

    Function TypedParam

    • Type safe URL parameter decorator.

      TypedParam is a decorator function getting specific typed parameter from the HTTP request URL. It's almost same with the nest.Param, but TypedParam automatically casts parameter value to be following its type, and validates it.

      import { tags } from "typia";

      \@TypedRoute.Get("shopping/sales/:id/:no/:paused")
      public async pause(
      \@TypedParam("id") id: string & tags.Format<"uuid">,
      \@TypedParam("no") no: number & tags.Type<"uint32">,
      \@TypedParam("paused") paused: boolean | null,
      ): Promise<void>;

      Type Parameters

      • T extends string | number | bigint | boolean | null

      Parameters

      • name: string

        URL Parameter name

      • Optionalassert: (value: string) => T

        Conversion and assertion supplied by the compile-time transform

      • Optionalvalidate: boolean

        Emit an errors array on validation failure when true; otherwise expose the first failure as flat path, reason, expected and value fields.

      Returns ParameterDecorator

      Parameter decorator

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

      contracts/common.md#principled-implementation The path parameter arrives as a string and is converted by the assertion function the transform generated for the declared type, so a value of the wrong type produces a 400 that names the parameter; the validate flag only changes the error body from the flat form to an errors array.

      contracts/common.md#clear-and-simple-design One decorator with one conversion function and one error-shaping branch.

      contracts/common.md#prohibited-implementation-shortcuts The conversion is generated from the declared type; without the transform the raw string is returned only when the configuration guard is off.

      contracts/common.md#meaningful-documentation The comment documents the supported types and the two error shapes.

      contracts/portability.md#os-neutral-implementation The named path segment is an HTTP route parameter whose text is decoded by the generated validator; no native path is resolved.