Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions docs/tutorial/getting-started/validation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,18 @@ Let's execrise 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)
```

Expand Down