Skip to main content

Function: record()

record<T, K>(model, constraints?): Arbitrary<{ [K in string | number | symbol]: (Partial<T> & Pick<T, K & keyof T>)[K] }>

Defined in: packages/fast-check/src/arbitrary/record.ts:56

For records following the recordModel schema

Type Parameters​

Type ParameterDefault type
T-
K extends string | number | symbolkeyof T

Parameters​

ParameterTypeDescription
model{ [K in string | number | symbol]: Arbitrary<T[K]> }-
constraints?RecordConstraints<K>Contraints on the generated record

Returns​

Arbitrary<{ [K in string | number | symbol]: (Partial<T> & Pick<T, K & keyof T>)[K] }>

Example​

record({ x: someArbitraryInt, y: someArbitraryInt }, {requiredKeys: []}): Arbitrary<{x?:number,y?:number}>
// merge two integer arbitraries to produce a {x, y}, {x}, {y} or {} record

Remarks​

Since 0.0.12