Skip to content

Standard schema validator - #8707

Open
gabrielgrant wants to merge 9 commits into
QwikDev:mainfrom
gabrielgrant:standard-schema-validator
Open

Standard schema validator#8707
gabrielgrant wants to merge 9 commits into
QwikDev:mainfrom
gabrielgrant:standard-schema-validator

Conversation

@gabrielgrant

Copy link
Copy Markdown
Contributor

What is it?

Feature / enhancement

Description

Moves forward the work started previously in #7518 and #7281 to add Standard Schema support

Checklist

  • My code follows the developer guidelines of this project
  • I performed a self-review of my own code
  • I added a changeset with pnpm change
  • I made corresponding changes to the Qwik docs
  • I added new tests to cover the fix / functionality

@gabrielgrant
gabrielgrant requested review from a team as code owners June 8, 2026 20:49
@changeset-bot

changeset-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dba8561

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@qwik.dev/router Minor
eslint-plugin-qwik Minor
@qwik.dev/core Minor
create-qwik Minor
@qwik.dev/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview dba8561

@gabrielgrant

Copy link
Copy Markdown
Contributor Author

AFAICT these CI failures seem to be timeouts setting up playwright, not actual failures, but I don't believe I'm able to re-run the jobs without pushing dummy commits to the branch

@gabrielgrant

gabrielgrant commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Would be great if @wmertens and @fabian-hiller could take a look at this when you have a moment. Thank you!

A few specific design questions:

  1. This adds types etc into the repo to avoid an additional dependency as suggested in feat: Add Standard Schema validator to qwik-city #7518 (comment) -- this is a question of Qwik policy/preferences (personally I'd generally go the other way and rely on upstream deps whenever possible, but I'm generally building projects, not frameworks)
  2. You'll probably notice StandardSchemaValidatorErrorKeyDotNotation is pretty verbose/complicated. Seems to work for nicer typing feedback than just Record<string, string[]>, but would certainly understand if the implementation complexity is deemed too high
  3. this implementation only gives access to the simplified dot notation -- it does not preserve the original Standard Schema issues array. May be worth changing that to also expose the original array too

@gabrielgrant
gabrielgrant force-pushed the standard-schema-validator branch from 052db94 to 5196de8 Compare June 26, 2026 12:31
@gabrielgrant
gabrielgrant changed the base branch from main to build/v2 June 26, 2026 12:31
@pkg-pr-new

pkg-pr-new Bot commented Jun 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

@qwik.dev/core

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@8707

@qwik.dev/router

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@8707

eslint-plugin-qwik

npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@8707

create-qwik

npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@8707

@qwik.dev/optimizer

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/optimizer@8707

commit: dba8561

@gabrielgrant

Copy link
Copy Markdown
Contributor Author

This is now rebased onto/PRed against build/v2

Since this was originally against v1, I left the existing explicit integrations with Valibot & Zod intact. If this is going to be added as part of the v2 transition, though, it's possible we may want to remove/deprecate those lib-specific integrations, and promote schema$ as the primary API. Thoughts?

```tsx
import { component$ } from '@qwik.dev/core';
import { Form, routeAction$, schema$ } from '@qwik.dev/router';
import { z } from 'zod';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you have to import * as z from 'zod' so that tree shaking works

Comment on lines +254 to +258
schema$(() =>
createStandardSchema<{ id: string }, { id: number }>((value) => ({
value: { id: Number((value as { id: string }).id) },
}))
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

QRLs can hold objects with functions in them, so maybe that would be a more ergonomic definition?

schema$({ validate: v => ({ value: { id:  Number((value as { id: string }).id) } })})

(no idea what I'm doing)

@wmertens
wmertens changed the base branch from build/v2 to main July 16, 2026 14:51
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.

2 participants