Check a create payload against its item type template
ztCheckPayload.RdVerifies what the campaigns checked by hand before creating records: every
field exists for the type, text fields are single strings, array and
object fields have the template's shape, each creator has an accepted type
and either a single name or both firstName and lastName, and no text
still carries an acquisition-site label. Problems are reported together in
one zotPlanError.
Usage
ztCheckPayload(
config,
payload,
template = ztTemplate(config, payload$itemType)
)Arguments
- config
A
zotConfig()object.- payload
A create payload (named list) with an
itemType.- template
The item type's
ztTemplate(); fetched when absent.
Examples
Template <- list(
itemType = "book", fields = c("itemType", "title", "creators", "tags"),
creatorTypes = "author",
template = list(itemType = "book", title = "", creators = list(), tags = list())
)
Payload <- list(itemType = "book", title = "A book",
creators = list(list(creatorType = "author", name = "Team")))
ztCheckPayload(config = NULL, payload = Payload, template = Template)