Support Valibot CLI metadata - #215
Open
ErickCReis wants to merge 2 commits into
Open
Conversation
ErickCReis
marked this pull request as ready for review
July 22, 2026 02:59
There was a problem hiding this comment.
ℹ️ 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 extraction —
src/json-schema.tsintroducesgetValibotCliMeta,getDeepValibotCliMeta, andapplyValibotCliMetadatato 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 intoconvertValibotToJsonSchema. - README documentation — adds Valibot examples alongside the existing zod/arktype metadata guidance.
- Test coverage —
test/valibot.test.tsadds tests for aliases, positional arguments (including merged and variadic), hidden options, and boolean negation.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Add support for trpc-cli-specific metadata on Valibot schemas:
aliaspositionalhiddennegatable@valibot/to-json-schemadoes not preserve customv.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 asoptionalandnullish. It also mirrors Valibot object requiredness into trpc-cli's existingoptionalmarker so optional positional arguments remain optional.The README documents Valibot metadata usage alongside the existing schema examples.
Tests
Coverage includes:
Validation
pnpm buildNODE_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 lintgit diff --check