Core
struct.record
Struct that parses an object with string keys and one value struct.
@defjs/core · Function
Signature
function record< S extends StructLike<unknown, unknown, boolean>, >(value: S): RecordStruct<S>;
-
Parses every own key of a plain object with
value. Anything else fails withinvalid_type(expectedrecord). -
Parsing stops at the first failing value, and
issue.pathholds its key. -
The output is a new object with a
nullprototype. -
Throws
TypeErrorwhenvalueis not a struct.
RecordStruct<S> is not exported. It is a Struct<{ [key: string]: StructInput<S> }, { [key: string]: Output }>, where Output is Infer<S> without undefined. When S is an optional struct, a value that is undefined omits its key from the output.
Parameters
Prop
Type
value S