Function validateEncode

  • Protocol Buffer Encoder with type validation.

    typia.protobuf.validateEncode() is a combination function of validation and encode.

    Therefore, it converts an input value to a binary data of Protocol Buffer, with type validation. If input value is not valid, it returns IValidation.IFailure value with detailed error reasons. Otherwise, there's no problem on the input value, Protocol Buffer binary data would be stored in data property of the output IValidation.ISuccess instance.

    If you can trust input value, or want to perform other type of validation, use below functions intead.

    By the way, you know what? Expression power of Protocol Buffer is not enough strong to fully meet the TypeScript type specs. In such reason, if you put a TypeScript type that is not compatible with Protocol Buffer, this function would throw compilation errors.

    Type Parameters

    • T

      Type of the value input

    Parameters

    • input: T

      A value to encode

    Returns IValidation<Uint8Array>

    Encoded binary data

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

  • Protocol Buffer Encoder with type validation.

    typia.protobuf.validateEncode() is a combination function of validation and encode.

    Therefore, it converts an input value to a binary data of Protocol Buffer, with type validation. If input value is not valid, it returns IValidation.IFailure value with detailed error reasons. Otherwise, there's no problem on the input value, Protocol Buffer binary data would be stored in data property of the output IValidation.ISuccess instance.

    If you can trust input value, or want to perform other type of validation, use below functions intead.

    By the way, you know what? Expression power of Protocol Buffer is not enough strong to fully meet the TypeScript type specs. In such reason, if you put a TypeScript type that is not compatible with Protocol Buffer, this function would throw compilation errors.

    Type Parameters

    • T

      Type of the value input

    Parameters

    • input: unknown

      A value to encode

    Returns IValidation<Uint8Array>

    Encoded binary data

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