Understand non-file field structure when attachFieldsToBody is true
mainWhen attachFieldsToBody: true is enabled, non-file fields are transformed into a complex object before validation. A field named hello with value world will appear in req.body as:
{
hello: {
fieldname: "hello",
value: "world",
fieldnameTruncated: false,
valueTruncated: false,
fields: body
}
}Important: Because this conversion happens before validation, your JSON Schema must account for this structure. For example, to validate the value property, your schema should look like:
hello: {
properties: {
value: {
type: 'string'
}
}
}If a field has a Content-Type header starting with application/json, it will be parsed using JSON.parse.