From 416c6e6e54ac3b7f06eb09771b55dcc875692cd7 Mon Sep 17 00:00:00 2001 From: Braden Wong <13159333+braden-w@users.noreply.github.com> Date: Fri, 5 Dec 2025 17:09:01 -0800 Subject: [PATCH] :wrench: fix: correct validation tutorial answer --- .../getting-started/validation/index.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/tutorial/getting-started/validation/index.md b/docs/tutorial/getting-started/validation/index.md index fe2dc7b1..4a71b7bd 100644 --- a/docs/tutorial/getting-started/validation/index.md +++ b/docs/tutorial/getting-started/validation/index.md @@ -128,15 +128,18 @@ Let's exercise what we have learned. We can define a schema by using `t.Object` provide to `body` property. ```typescript -import { Elysia } from 'elysia' +import { Elysia, t } from 'elysia' new Elysia() - .get('/', ({ status, set }) => { - set.headers['x-powered-by'] = 'Elysia' - - return status(418, 'Hello Elysia!') - }) - .get('/docs', ({ redirect }) => redirect('https://elysiajs.com')) + .post( + '/user', + ({ body: { name } }) => `Hello ${name}!`, + { + body: t.Object({ + name: t.String() + }) + } + ) .listen(3000) ```