Skip to content

refactor: replace valibot with minimal inline StandardSchemaV1 schemas#5

Merged
psd-coder merged 1 commit intomainfrom
get-rid-of-valibot-dependency
Apr 2, 2026
Merged

refactor: replace valibot with minimal inline StandardSchemaV1 schemas#5
psd-coder merged 1 commit intomainfrom
get-rid-of-valibot-dependency

Conversation

@psd-coder
Copy link
Copy Markdown
Owner

Overview

Removes valibot as a runtime/bundled dependency by replacing it with minimal inline schema
helpers that implement the StandardSchemaV1 protocol directly.

Problem Statement

valibot was a runtime dependency bundled into the library output, adding unnecessary weight. The
library only used a small subset of valibot's API (type coercion and basic validation) and the
StandardSchemaV1 protocol it already depends on is sufficient to implement those directly — no
third-party schema library is needed at runtime.

Solution Approach

  • Replaced all valibot schema usage in builders.ts with three small helpers:
    • schema() — creates a raw StandardSchemaV1-conforming object
    • propSchema() — wraps coercion logic with fallback resolution and nullable short-circuit,
      eliminating the repeated pattern across all prop builders
    • fail() — constructs a StandardSchemaV1 issue result, deduplicating the error path across
      number, oneOf, and refSchema validators
  • Moved valibot to devDependencies so it remains available for tests, where it serves as an
    example of a user-provided StandardSchemaV1-compatible schema passed to propBuilders.json()
  • Updated the bundle size limit to reflect the new output (±30 B vs original)

Breaking Changes

None.

Testing

All existing tests pass.

@psd-coder psd-coder self-assigned this Apr 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 2, 2026

size-limit report 📦

Path Size
.size-check/index.mjs 2.35 KB (+0.76% 🔺)
.size-check/render.mjs 410 B (0%)
.size-check/context.mjs 402 B (0%)

@psd-coder psd-coder force-pushed the get-rid-of-valibot-dependency branch from e40e22f to 52292a2 Compare April 2, 2026 22:27
Removes valibot as a runtime dependency; implements custom schema/propSchema helpers for coercion and ref validation. Moves valibot to devDependencies for test-only use.
@psd-coder psd-coder force-pushed the get-rid-of-valibot-dependency branch from 52292a2 to 36fe616 Compare April 2, 2026 22:29
@psd-coder psd-coder merged commit 44fdc6f into main Apr 2, 2026
4 checks passed
@psd-coder psd-coder deleted the get-rid-of-valibot-dependency branch April 2, 2026 22:30
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