Summary
As a package developer, in order to model JSON Schema additionalProperties, I would like to control whether stabilize_lst() permits named elements that are not covered by a spec, and optionally validate them against a schema.
Details
By default stabilize_lst() rejects any extra named element:
stabilize_lst(list(a = 1L, z = 99L), a = specify_int())
#> Error: `list(...)` must not contain extra named elements. Extra element: "z"
JSON Schema additionalProperties is more flexible: it may be true (allow any extras — the JSON Schema default), false (forbid extras — stbl's current behavior), or a schema that every extra property must satisfy. stabilize_df() already has .extra_cols; stabilize_lst() needs the analogous control for named elements.
Proposed signature
stabilize_lst(x, ..., .extra = NULL)
Arguments
.extra — Controls handling of named elements not named in ...: forbid (current default), allow unchecked, or a stabilizer / specify_*() spec that each extra element must satisfy.
Returns the (coerced) list.
Behavior
- Preserve the current "forbid extras" behavior as the default to avoid a breaking change (note: this differs from JSON Schema's permissive default; the converter layer can bridge that).
- When a spec is supplied, validate every extra named element against it, reporting failures with their names/locations.
- Also update
specify_lst() to match this update.
References
Summary
Details
By default
stabilize_lst()rejects any extra named element:JSON Schema
additionalPropertiesis more flexible: it may betrue(allow any extras — the JSON Schema default),false(forbid extras — stbl's current behavior), or a schema that every extra property must satisfy.stabilize_df()already has.extra_cols;stabilize_lst()needs the analogous control for named elements.Proposed signature
Arguments
.extra— Controls handling of named elements not named in...: forbid (current default), allow unchecked, or a stabilizer /specify_*()spec that each extra element must satisfy.Returns the (coerced) list.
Behavior
specify_lst()to match this update.References