CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-io-ts

TypeScript runtime type system for IO decoding/encoding

72

1.14x
Overview
Eval results
Files

task.mdevals/scenario-7/

Configuration Key Validator

Build a configuration validation system that validates configuration keys against a predefined set of allowed keys. The system should define a set of valid configuration options (e.g., "timeout", "retries", "maxConnections") and ensure that only keys from this set are accepted.

Requirements

Validates allowed configuration keys

The system must accept only valid configuration keys from a predefined set of allowed options (at least 3 different valid keys).

  • When given a valid configuration key like "timeout", it validates successfully @test
  • When given an invalid configuration key like "invalid_option", it rejects the value @test

Handles configuration objects with key validation

The system must validate that configuration objects only contain keys from the allowed set.

  • When given an object with valid keys like { setting: "timeout" }, it validates successfully @test
  • When given an object with an invalid key reference, it rejects the object @test

Implementation

@generates

API

/**
 * Validates configuration keys against allowed options
 * Returns Either with validation result
 */
export function validateConfigKey(key: unknown): unknown;

/**
 * Validates a configuration object containing a key field
 * Returns Either with validation result
 */
export function validateConfigObject(config: unknown): unknown;

Dependencies { .dependencies }

io-ts { .dependency }

Provides runtime type validation support.

fp-ts { .dependency }

Provides functional programming utilities for Either types.

Install with Tessl CLI

npx tessl i tessl/npm-io-ts

tile.json