Skip to content

fix: fix the docs about schema, global schema using guard #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Changes from all commits
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
6 changes: 3 additions & 3 deletions docs/essential/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ new Elysia()
.listen(3000)
```

This code ensures that the query must have **name** with a string value for every handler after it. The response should be listed as follows:

<Playground
:elysia="demo2"
:mock="{
Expand All @@ -140,6 +142,4 @@ The response should be listed as follows:
| /query | error |
| /query?name=a | a |

As Lifecycle Event, it is important to remember that the order of Elysia's schema is stored as same as lifecycle, a queue, or first-in-first-out.

Elysia **always** respects the order of code from top to bottom followed by the order of life-cycle event and validation schema.
If multiple global schemas are defined for same property, the latest one will have the preference. If both local and global schemas are defined, the local one will have the preference.