Skip to content

Commit 9bebf8d

Browse files
rename inputValidator to validator (#7566)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 10a7ff8 commit 9bebf8d

212 files changed

Lines changed: 635 additions & 402 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/clean-rules-warn.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@tanstack/react-start': patch
3+
'@tanstack/solid-start': patch
4+
'@tanstack/vue-start': patch
5+
'@tanstack/start-client-core': patch
6+
'@tanstack/start-plugin-core': patch
7+
---
8+
9+
Add `validator()` as the canonical server function and middleware validator method. Deprecate `inputValidator()` and emit compiler warnings for remaining uses.

_artifacts/start_domain_map.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ skills:
134134
- '@tanstack/start-server-core'
135135
covers:
136136
- createServerFn (GET/POST)
137-
- inputValidator (Zod or function)
137+
- validator (Zod or function)
138138
- useServerFn hook
139139
- Server context utilities (getRequest, getRequestHeader, setResponseHeader, setResponseStatus)
140140
- Error handling (throw errors, redirect, notFound)
@@ -229,7 +229,7 @@ skills:
229229
- Middleware factories
230230
- Fetch override precedence
231231
- Header merging
232-
- Method order enforcement (middleware → inputValidator → client → server)
232+
- Method order enforcement (middleware → validator → client → server)
233233
tasks:
234234
- 'Add authentication middleware'
235235
- 'Pass context through middleware chain'
@@ -247,7 +247,7 @@ skills:
247247

248248
- mistake: 'Wrong middleware method order'
249249
mechanism: >-
250-
TypeScript enforces method order: middleware → inputValidator
250+
TypeScript enforces method order: middleware → validator
251251
→ client → server. Wrong order causes type errors and
252252
runtime failures.
253253
source: 'docs/start/framework/react/guide/middleware.md'

_artifacts/start_skill_tree.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ skills:
3737
path: 'skills/start-core/server-functions/SKILL.md'
3838
package: 'packages/start-client-core'
3939
description: >-
40-
createServerFn (GET/POST), inputValidator (Zod or function),
40+
createServerFn (GET/POST), validator (Zod or function),
4141
useServerFn hook, server context utilities (getRequest,
4242
getRequestHeader, setResponseHeader, setResponseStatus), error
4343
handling (throw errors, redirect, notFound), streaming

docs/start/framework/react/build-from-scratch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ const getCount = createServerFn({
290290
})
291291

292292
const updateCount = createServerFn({ method: 'POST' })
293-
.inputValidator((d: number) => d)
293+
.validator((d: number) => d)
294294
.handler(async ({ data }) => {
295295
const count = await readCount()
296296
await fs.promises.writeFile(filePath, `${count + data}`)

docs/start/framework/react/comparison.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function Post() {
188188

189189
```tsx
190190
export const getTodos = createServerFn({ method: 'GET' })
191-
.inputValidator(zodValidator(z.object({ userId: z.string() })))
191+
.validator(zodValidator(z.object({ userId: z.string() })))
192192
.middleware([authMiddleware])
193193
.handler(async ({ data, context }) => {
194194
// Fully typed data and context

docs/start/framework/react/guide/authentication-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ Build your own authentication system using TanStack Start's server functions and
212212
- Use HTTPS in production and set a strong session secret.
213213
- Store sessions in `HttpOnly`, `Secure`, `SameSite` cookies. Do not store session tokens in `localStorage` or `sessionStorage`.
214214
- Enforce auth in every server function, server route, or API endpoint that reads or writes private user, tenant, or account data. Use `beforeLoad` for page UX, not as the data boundary.
215-
- Use `.inputValidator()` on every server function that accepts input.
215+
- Use `.validator()` on every server function that accepts input.
216216
- Hash passwords with bcrypt, scrypt, or Argon2. For missing users, verify against a dummy hash and return the same login/reset message.
217217
- Rate limit login, registration, and password-reset endpoints.
218218
- Use CSRF or same-origin protections for non-GET server functions and server routes.

docs/start/framework/react/guide/authentication-server-primitives.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ import { z } from 'zod'
119119
import { setSessionCookie } from './session'
120120

121121
export const login = createServerFn({ method: 'POST' })
122-
.inputValidator(z.object({ email: z.string().email(), password: z.string() }))
122+
.validator(z.object({ email: z.string().email(), password: z.string() }))
123123
.handler(async ({ data }) => {
124124
const user = await db.users.findByEmail(data.email)
125125
// Always run verifyPasswordHash — even when the user doesn't exist —
@@ -228,7 +228,7 @@ import { createServerFn } from '@tanstack/react-start'
228228
import { z } from 'zod'
229229

230230
export const requestPasswordReset = createServerFn({ method: 'POST' })
231-
.inputValidator(z.object({ email: z.string().email() }))
231+
.validator(z.object({ email: z.string().email() }))
232232
.handler(async ({ data }) => {
233233
const user = await db.users.findByEmail(data.email)
234234
if (user) {

docs/start/framework/react/guide/authentication.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import { redirect } from '@tanstack/react-router'
5050

5151
// Login server function
5252
export const loginFn = createServerFn({ method: 'POST' })
53-
.inputValidator((data: { email: string; password: string }) => data)
53+
.validator((data: { email: string; password: string }) => data)
5454
.handler(async ({ data }) => {
5555
// Verify credentials (replace with your auth logic)
5656
const user = await authenticateUser(data.email, data.password)
@@ -221,9 +221,7 @@ import { createServerFn } from '@tanstack/react-start'
221221

222222
// User registration
223223
export const registerFn = createServerFn({ method: 'POST' })
224-
.inputValidator(
225-
(data: { email: string; password: string; name: string }) => data,
226-
)
224+
.validator((data: { email: string; password: string; name: string }) => data)
227225
.handler(async ({ data }) => {
228226
// Check if user exists
229227
const existingUser = await getUserByEmail(data.email)
@@ -305,7 +303,7 @@ export const authProviders = {
305303
}
306304

307305
export const initiateOAuthFn = createServerFn({ method: 'POST' })
308-
.inputValidator((data: { provider: 'google' | 'github' }) => data)
306+
.validator((data: { provider: 'google' | 'github' }) => data)
309307
.handler(async ({ data }) => {
310308
const provider = authProviders[data.provider]
311309
const state = generateRandomState()
@@ -326,7 +324,7 @@ export const initiateOAuthFn = createServerFn({ method: 'POST' })
326324
```tsx
327325
// Password reset request
328326
export const requestPasswordResetFn = createServerFn({ method: 'POST' })
329-
.inputValidator((data: { email: string }) => data)
327+
.validator((data: { email: string }) => data)
330328
.handler(async ({ data }) => {
331329
const user = await getUserByEmail(data.email)
332330
if (!user) {
@@ -345,7 +343,7 @@ export const requestPasswordResetFn = createServerFn({ method: 'POST' })
345343

346344
// Password reset confirmation
347345
export const resetPasswordFn = createServerFn({ method: 'POST' })
348-
.inputValidator((data: { token: string; newPassword: string }) => data)
346+
.validator((data: { token: string; newPassword: string }) => data)
349347
.handler(async ({ data }) => {
350348
const resetToken = await getPasswordResetToken(data.token)
351349

@@ -426,7 +424,7 @@ const loginSchema = z.object({
426424
})
427425

428426
export const loginFn = createServerFn({ method: 'POST' })
429-
.inputValidator((data) => loginSchema.parse(data))
427+
.validator((data) => loginSchema.parse(data))
430428
.handler(async ({ data }) => {
431429
// data is now validated
432430
})
@@ -522,7 +520,7 @@ function LoginForm() {
522520

523521
```tsx
524522
export const loginFn = createServerFn({ method: 'POST' })
525-
.inputValidator(
523+
.validator(
526524
(data: { email: string; password: string; rememberMe?: boolean }) => data,
527525
)
528526
.handler(async ({ data }) => {

docs/start/framework/react/guide/environment-variables.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const connectToDatabase = createServerFn().handler(async () => {
7777

7878
// Authentication (server-only)
7979
const authenticateUser = createServerFn()
80-
.inputValidator(z.object({ token: z.string() }))
80+
.validator(z.object({ token: z.string() }))
8181
.handler(async ({ data }) => {
8282
const jwtSecret = process.env.JWT_SECRET // Server-only
8383
return jwt.verify(data.token, jwtSecret)
@@ -257,7 +257,7 @@ import { createServerFn } from '@tanstack/react-start'
257257
258258
// Server-side API calls (can use secret keys)
259259
const fetchUserData = createServerFn()
260-
.inputValidator(z.object({ userId: z.string() }))
260+
.validator(z.object({ userId: z.string() }))
261261
.handler(async ({ data }) => {
262262
const response = await fetch(
263263
`${process.env.EXTERNAL_API_URL}/users/${data.userId}`,

docs/start/framework/react/guide/execution-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import { createServerFn, createServerOnlyFn } from '@tanstack/react-start'
6262

6363
// RPC: Server execution, callable from client
6464
const updateUser = createServerFn({ method: 'POST' })
65-
.inputValidator((data: UserData) => data)
65+
.validator((data: UserData) => data)
6666
.handler(async ({ data }) => {
6767
// Only runs on server, but client can call it
6868
return await db.users.update(data)

0 commit comments

Comments
 (0)