CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-io-ts

tessl install tessl/npm-io-ts@2.2.0

TypeScript runtime type system for IO decoding/encoding

Agent Success

Agent success rate when using this tile

72%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.14x

Baseline

Agent success rate without this tile

63%

task.mdevals/scenario-9/

API Response Validator

A validator for handling API responses that can return different types of data based on the operation result.

Capabilities

Validate success responses

  • A response with status "success" and data containing a user object (id: number, name: string) is validated successfully @test
  • A response with status "success" but missing the data field is rejected with validation errors @test

Validate error responses

  • A response with status "error" and an error object (code: string, message: string) is validated successfully @test
  • A response with status "error" but missing the error field is rejected with validation errors @test

Validate loading responses

  • A response with status "loading" and no additional fields is validated successfully @test
  • A response with an unrecognized status value is rejected with validation errors @test

Implementation

@generates

API

/**
 * Validates an API response that can be in one of three states:
 * - Success: Contains user data
 * - Error: Contains error information
 * - Loading: Indicates operation in progress
 *
 * @param response - The API response object to validate
 * @returns Either an array of validation errors or the validated response
 */
export function validateResponse(response: unknown): any;

Dependencies { .dependencies }

io-ts { .dependency }

Provides runtime type validation with union type support.

@satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/io-ts@2.2.x
tile.json