Skip to content

Support Valibot CLI metadata - #215

Open
ErickCReis wants to merge 2 commits into
mmkal:mainfrom
ErickCReis:codex/valibot-cli-metadata
Open

Support Valibot CLI metadata#215
ErickCReis wants to merge 2 commits into
mmkal:mainfrom
ErickCReis:codex/valibot-cli-metadata

Conversation

@ErickCReis

@ErickCReis ErickCReis commented Jul 22, 2026

Copy link
Copy Markdown

Summary

Add support for trpc-cli-specific metadata on Valibot schemas:

  • alias
  • positional
  • hidden
  • negatable

@valibot/to-json-schema does not preserve custom v.metadata(...) values. This change reapplies those fields after conversion while retaining the converter's JSON Schema output. It handles metadata on object entries, array and tuple items, and wrapped schemas such as optional and nullish. It also mirrors Valibot object requiredness into trpc-cli's existing optional marker so optional positional arguments remain optional.

The README documents Valibot metadata usage alongside the existing schema examples.

Tests

Coverage includes:

  • aliases
  • required and optional positional arguments
  • merged procedure inputs
  • variadic array positionals
  • hidden options
  • enabled and explicitly disabled boolean negation
  • metadata inside and outside wrapper schemas

Validation

  • pnpm build
  • NODE_NO_WARNINGS=1 pnpm exec vitest run test/valibot.test.ts (42 passed)
  • NODE_NO_WARNINGS=1 pnpm test (426 passed, 2 skipped, no type errors)
  • pnpm lint
  • git diff --check

@ErickCReis
ErickCReis marked this pull request as ready for review July 22, 2026 02:59

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — minor suggestions inline.

Reviewed changes — adds support for trpc-cli-specific metadata (alias, positional, hidden, negatable) on Valibot schemas by reapplying v.metadata(...) fields after @valibot/to-json-schema conversion, and mirrors Valibot requiredness into the internal optional marker.

  • Valibot metadata extractionsrc/json-schema.ts introduces getValibotCliMeta, getDeepValibotCliMeta, and applyValibotCliMetadata to walk wrapper schemas, copy CLI-specific metadata onto the converted JSON schema, and recurse into objects, arrays, and tuples.
  • Valibot-to-JSON conversion refactor — extracts the existing v.object({child: input}) wrapping logic into convertValibotToJsonSchema.
  • README documentation — adds Valibot examples alongside the existing zod/arktype metadata guidance.
  • Test coveragetest/valibot.test.ts adds tests for aliases, positional arguments (including merged and variadic), hidden options, and boolean negation.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

Comment thread src/json-schema.ts Outdated
Comment thread src/json-schema.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant