Documentation
    Preparing search index...

    Function TypedQuery

    • Type safe URL query decorator.

      TypedQuery is a decorator function that can parse URL query string. It is almost same with nest.Query, but it can automatically cast property type following its DTO definition. Also, TypedQuery performs type validation.

      For reference, target type T must follow such restriction. Also, if actual URL query parameter values are different with their promised type T, BadRequestException error (status code: 400) would be thrown.

      1. Type T must be an object type
      2. Do not allow dynamic property
      3. Only boolean, bigint, number, string or their array types are allowed
      4. By the way, union type never be not allowed

      Type Parameters

      • T extends object

      Parameters

      • Optionalvalidator: IRequestQueryValidator<T>

      Returns ParameterDecorator

      Parameter decorator

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

      contracts/common.md#principled-implementation The query string is read from the request URL after the first question mark, grouped by the transformed decoder into the typed object, and a failure is thrown as the 400 response; the decoder receives a URLSearchParams, so both Express and Fastify requests are handled by the same code.

      contracts/common.md#clear-and-simple-design One parameter decorator on top of the shared query validator runner.

      contracts/common.md#prohibited-implementation-shortcuts The decoder is generated from the type by the transform; without it the grouped raw query is returned only when the configuration guard is off.

      contracts/common.md#meaningful-documentation The comment documents the supported property types and the validation modes.

      contracts/portability.md#os-neutral-implementation Query decoding and response encoding operate on URLSearchParams and HTTP route metadata rather than native filesystem paths.