From 7b0d1ead67c9e23c5cab0ab819c181a9586f3d1e Mon Sep 17 00:00:00 2001 From: Kocunu Date: Sun, 7 Dec 2025 14:00:35 +0100 Subject: [PATCH] fix: Fix validation tutorial answer snippet. fix#750 --- .../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) ```