Nitro · Request

NITRO0006Use getValidatedQuery for validated query strings

When a Nitro handler validates query input, read and validate it through the H3 utility.

Why it happens

Raw request input and validation can drift apart when they are separate operations. Nitro and h3 provide validated helpers that keep parsing and validation coupled at the request boundary.

Fix

Use getValidatedQuery(event, validator) instead of getQuery(event) followed by separate validation.

Example

Keep reading and validation together

Before

export default defineEventHandler(async (event) => {
  const input = await getQuery(event)
  const value = validator.parse(input)

  return value
})

After

export default defineEventHandler(async (event) => {
  const value = await getValidatedQuery(event, validator)

  return value
})

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --framework nitro --rules nitro/request/prefer-validated-query
Copyright © 2026