Normalize a form payload into the shape the API expects.
Recursively walks data against fields and:
data
fields
x-fk.value
null
""
refSchema
{}
[]
Fields not present in fields are copied through untouched.
The raw form value (object or array).
Field metadata for the current level.
The spec's components.schemas (for inline-ref recursion).
components.schemas
Optional
Resolves FK values to objects (defaults to identity).
A new, normalized payload.
const body = await sanitizePayload(form, resource.fields, schemas, resolveFk); Copy
const body = await sanitizePayload(form, resource.fields, schemas, resolveFk);
Normalize a form payload into the shape the API expects.
Recursively walks
dataagainstfieldsand:x-fk.value(id -> object), mappingnull/""tonull(or resolving each element for FK arrays);refSchema) objects using the referenced schema's fields, mapping empty values to{}or[];[]and empty object fields to{}.Fields not present in
fieldsare copied through untouched.