Skip to content

Commit 7988243

Browse files
committed
docs(cross-link): connect pages to validation
- Add validation links from body limit and file upload pages - Add validation links from json and request handling pages - Add validation links from route patterns, teams, and xss pages - Mirror every cross-link in Indonesian
1 parent 2420fa7 commit 7988243

14 files changed

Lines changed: 32 additions & 4 deletions

File tree

docs/by-design/xss.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ Some values are meant to be HTML, such as content from a trusted editor. Triple
3232
<p>{{{ trustedHtml }}}</p>
3333
```
3434

35-
The opt-out is deliberate and local, so the default stays safe and only the value that needs raw markup is marked as such. Sending JSON needs no escaping at all, since the data is never parsed as markup, covered in [JSON responses](/response/json). Checking the shape and type of incoming data is a separate task for the handler after [reading the body](/core-concepts/context-object#request-data-access), which is validation rather than escaping.
35+
The opt-out is deliberate and local, so the default stays safe and only the value that needs raw markup is marked as such. Sending JSON needs no escaping at all, since the data is never parsed as markup, covered in [JSON responses](/response/json). Checking the shape and type of incoming data is a separate task that runs before the handler through a [validation](/middleware/validation/overview) contract, which is validation rather than escaping.

docs/core-concepts/request-handling.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,7 @@ const sessionId = ctx.cookie('sessionId')
270270
// Get all cookies
271271
const cookies = ctx.cookie() // { sessionId: 'abc123', theme: 'dark' }
272272
```
273+
274+
## Validating Before The Handler
275+
276+
Every reader above hands back the raw value as it arrived, so a handler still checks the shape itself. A schema moves those checks ahead of the handler, runs a contract against each source, and leaves only data that already passed. See [Validation Overview](/middleware/validation/overview) for how `ctx.json()`, `ctx.query()`, and the other readers feed a contract.

docs/core-concepts/route-patterns.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,5 @@ export function GET(ctx: Context): Response {
106106
})
107107
}
108108
```
109+
110+
A handler that validates several params, or wants the failure to carry field-level reasons, runs a [validation](/middleware/validation/overview) contract with `Validator.check` instead of an inline regex. Params are checked inside the handler because they resolve after middleware runs, covered in [Reading Validated Data](/middleware/validation/reading-data#checking-params-in-a-handler).

docs/getting-started/built-for-teams.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ router.use(
9999
await router.serve(8000)
100100
```
101101

102-
Handlers stay focused on their own job, while shared behavior is applied once. The full set of building blocks is in [Global Middleware](/middleware/global), and errors flow to one place through [error handling](/error-handling/object-details).
102+
Handlers stay focused on their own job, while shared behavior is applied once. The full set of building blocks is in [Global Middleware](/middleware/global), and errors flow to one place through [error handling](/error-handling/object-details). Input rules belong here too, where a [validation](/middleware/validation/overview) contract checks a request before the handler so each route reads only data that already passed.
103103

104104
![Shared rules in one place: securityHeaders() registered with router.use(fn) reaches every route, while basicAuth() registered with router.use('/admin', fn) reaches only /admin/*, so one developer can own auth and another own logging without touching each other's route files](/diagrams/team-shared-rules.png)
105105

docs/id/by-design/xss.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ Beberapa nilai memang dimaksudkan jadi HTML, seperti konten dari editor tepercay
3232
<p>{{{ trustedHtml }}}</p>
3333
```
3434

35-
Opt-out ini sengaja dan lokal, jadi default tetap aman dan hanya nilai yang butuh markup mentah yang ditandai begitu. Mengirim JSON sama sekali tak butuh escaping, karena data tak pernah diurai sebagai markup, dibahas di [response JSON](/id/response/json). Memeriksa bentuk dan tipe data masuk adalah tugas terpisah untuk handler setelah [membaca body](/id/core-concepts/context-object#akses-data-request), yang merupakan validasi ketimbang escaping.
35+
Opt-out ini sengaja dan lokal, jadi default tetap aman dan hanya nilai yang butuh markup mentah yang ditandai begitu. Mengirim JSON sama sekali tak butuh escaping, karena data tak pernah diurai sebagai markup, dibahas di [response JSON](/id/response/json). Memeriksa bentuk dan tipe data masuk adalah tugas terpisah yang berjalan sebelum handler lewat kontrak [validasi](/id/middleware/validation/overview), yang merupakan validasi ketimbang escaping.

docs/id/core-concepts/request-handling.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,7 @@ const sessionId = ctx.cookie('sessionId')
270270
// Ambil semua cookie
271271
const cookies = ctx.cookie() // { sessionId: 'abc123', theme: 'dark' }
272272
```
273+
274+
## Memvalidasi Sebelum Handler
275+
276+
Setiap pembaca di atas mengembalikan nilai mentah seperti saat tiba, jadi handler tetap memeriksa bentuknya sendiri. Sebuah schema memindahkan pemeriksaan itu ke depan handler, menjalankan kontrak terhadap tiap sumber, dan menyisakan hanya data yang sudah lolos. Lihat [Ringkasan Validasi](/id/middleware/validation/overview) untuk bagaimana `ctx.json()`, `ctx.query()`, dan pembaca lain mengisi sebuah kontrak.

docs/id/core-concepts/route-patterns.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,5 @@ export function GET(ctx: Context): Response {
106106
})
107107
}
108108
```
109+
110+
Handler yang memvalidasi beberapa param, atau ingin kegagalannya membawa alasan tingkat field, menjalankan kontrak [validasi](/id/middleware/validation/overview) dengan `Validator.check` alih-alih regex inline. Param diperiksa di dalam handler karena baru tersedia setelah middleware berjalan, dibahas di [Membaca Data Tervalidasi](/id/middleware/validation/reading-data#memeriksa-params-di-handler).

docs/id/getting-started/built-for-teams.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ router.use(
9999
await router.serve(8000)
100100
```
101101

102-
Handler tetap fokus pada tugasnya sendiri, sementara perilaku bersama diterapkan sekali. Set lengkap blok penyusunnya ada di [Global Middleware](/id/middleware/global), dan error mengalir ke satu tempat lewat [penanganan error](/id/error-handling/object-details).
102+
Handler tetap fokus pada tugasnya sendiri, sementara perilaku bersama diterapkan sekali. Set lengkap blok penyusunnya ada di [Global Middleware](/id/middleware/global), dan error mengalir ke satu tempat lewat [penanganan error](/id/error-handling/object-details). Aturan input juga ada di sini, tempat kontrak [validasi](/id/middleware/validation/overview) memeriksa request sebelum handler sehingga tiap rute hanya membaca data yang sudah lolos.
103103

104104
![Aturan bersama di satu tempat: securityHeaders() yang didaftarkan dengan router.use(fn) menjangkau setiap rute, sedangkan basicAuth() yang didaftarkan dengan router.use('/admin', fn) hanya menjangkau /admin/*, jadi satu developer bisa memegang auth dan yang lain memegang logging tanpa menyentuh berkas rute satu sama lain](/diagrams/team-shared-rules.png)
105105

docs/id/middleware/body-limit.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ Ketika request bisa membawa body, middleware memeriksa ukuran yang dideklarasika
8282
- Ketika `Transfer-Encoding` dan `Content-Length` sama-sama ada, `Transfer-Encoding` didahulukan.
8383
- Body chunked atau panjang tak diketahui tetap dibatasi oleh stream yang dibungkus, dan hanya byte yang dibaca yang dihitung terhadap batas.
8484

85+
Middleware ini membatasi berapa byte yang boleh dibawa sebuah body. Memeriksa bentuk byte itu adalah langkah terpisah yang dijalankan kontrak [validasi](/id/middleware/validation/overview) setelah body berada dalam batas.
86+
8587
## Contoh Lengkap
8688

8789
```typescript twoslash

docs/id/recipes/file-upload.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ export async function POST(ctx: Context): Promise<Response> {
7676

7777
Objek `File` memaparkan `name`, `type`, dan `size` miliknya sendiri, jadi melaporkan kembali sebuah upload tidak pernah perlu menyentuh disk.
7878

79+
Handler yang memeriksa beberapa field bisa memindahkan pemeriksaan itu ke depan dirinya dengan kontrak [validasi](/id/middleware/validation/overview) pada sumber `body`, sehingga hanya request yang sudah membawa field yang benar mencapai handler.
80+
7981
## Menyimpan ke Disk
8082

8183
Bytes tetap di dalam `File` sampai `arrayBuffer()` mengeluarkannya, dan membungkus buffer itu dalam `Uint8Array` memberi [`Deno.writeFile`](https://docs.deno.com/api/deno/~/Deno.writeFile) persis bentuk yang diharapkannya. Deserve tidak pernah menulis upload sendiri, jadi path tujuan tetap dalam kendali penuh:

0 commit comments

Comments
 (0)