Function assertDecode

  • You must configure the generic argument T.

    Protocol Buffer Decoder wity type assertion, but not safe.

    typia.protobuf.assertDecode() is a combination function of decode and assert function. Therefore, it decodes a binary data of Protocol Buffer to a TypeScript instance, and performs type assertion process. If decoded value is following the type T, it returns the decoded value. Otherwise, it throws TypeGuardError instead.

    However, note that, this validation is not always safe. It just performs additional type assertion like number & Minimum<7> or string & Format<"uuid"> cases, that are represented by custom tags. Therefore, when using typia.protobuf.assertDecode<T>() function, you have to ensure the type safety by yourself.

    In such type safety reason, I recommend you to use type safe encode functions.

    Parameters

    • input: Uint8Array

      Protobuf Buffer binary data

    • OptionalerrorFactory: ((props: TypeGuardError.IProps) => Error)

      Custom error factory. Default is TypeGuardError

    Returns never

    Decoded value

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

  • Protocol Buffer Decoder wity type assertion, but not safe.

    typia.protobuf.assertDecode() is a combination function of decode and assert function. Therefore, it decodes a binary data of Protocol Buffer to a TypeScript instance, and performs type assertion process. If decoded value is following the type T, it returns the decoded value. Otherwise, it throws TypeGuardError instead.

    However, note that, this validation is not always safe. It just performs additional type assertion like number & Minimum<7> or string & Format<"uuid"> cases, that are represented by custom tags. Therefore, when using typia.protobuf.assertDecode<T>() function, you have to ensure the type safety by yourself.

    In such type safety reason, I recommend you to use type safe encode functions.

    Type Parameters

    • T

      Expected type of decoded value

    Parameters

    • input: Uint8Array

      Protobuf Buffer binary data

    • OptionalerrorFactory: ((props: TypeGuardError.IProps) => Error)

      Custom error factory. Default is TypeGuardError

    Returns Resolved<T>

    Decoded value

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