Skip to content

Commit 9ff3c28

Browse files
authored
docs: update for attachFieldsToBody: keyValues (#492)
* docs: update for attachFieldsToBody: keyValues * fix docs to match fastify style guide
1 parent e497c21 commit 9ff3c28

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ If you try to read from a stream and pipe to a new file, you will obtain an empt
288288

289289
## JSON Schema body validation
290290

291-
If you enable `attachFieldsToBody: 'keyValues'` then the response body and JSON Schema validation will behave similarly to `application/json` and [`application/x-www-form-urlencoded`](https://github.com/fastify/fastify-formbody) content types. Files will be decoded using `Buffer.toString()` and attached as a body value.
291+
When the `attachFieldsToBody` parameter is set to `'keyValues'`, JSON Schema validation on the body will behave similarly to `application/json` and [`application/x-www-form-urlencoded`](https://github.com/fastify/fastify-formbody) content types. Additionally, uploaded files will be attached to the body as `Buffer` objects.
292292

293293
```js
294294
fastify.register(require('@fastify/multipart'), { attachFieldsToBody: 'keyValues' })
@@ -302,9 +302,7 @@ fastify.post('/upload/files', {
302302
properties: {
303303
// file that gets decoded to string
304304
myFile: {
305-
type: 'string',
306-
// validate that file contents match a UUID
307-
pattern: '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'
305+
type: 'object',
308306
},
309307
hello: {
310308
type: 'string',

0 commit comments

Comments
 (0)