Constraints for anything and object

interface ObjectConstraints {
    depthSize?: DepthSize;
    key?: Arbitrary<string>;
    maxDepth?: number;
    maxKeys?: number;
    size?: SizeForArbitrary;
    values?: Arbitrary<unknown>[];
    withBigInt?: boolean;
    withBoxedValues?: boolean;
    withDate?: boolean;
    withMap?: boolean;
    withNullPrototype?: boolean;
    withObjectString?: boolean;
    withSet?: boolean;
    withSparseArray?: boolean;
    withTypedArray?: boolean;
    withUnicodeString?: boolean;
}

Properties

depthSize?: DepthSize

Limit the depth of the object by increasing the probability to generate simple values (defined via values) as we go deeper in the object.

Since 2.20.0

key?: Arbitrary<string>

Arbitrary for keys

string

Since 0.0.7

maxDepth?: number

Maximal depth allowed

Number.POSITIVE_INFINITY — defaulting seen as "max non specified" when defaultSizeToMaxWhenMaxSpecified=true

Since 0.0.7

maxKeys?: number

Maximal number of keys

0x7fffffff — defaulting seen as "max non specified" when defaultSizeToMaxWhenMaxSpecified=true

Since 1.13.0

Define how large the generated values should be (at max)

Since 2.22.0

values?: Arbitrary<unknown>[]

Arbitrary for values

boolean, integer, double, string, null, undefined, Number.NaN, +0, -0, Number.EPSILON, Number.MIN_VALUE, Number.MAX_VALUE, Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY

Since 0.0.7

withBigInt?: boolean

Also generate BigInt

false

Since 1.26.0

withBoxedValues?: boolean

Also generate boxed versions of values

false

Since 1.11.0

withDate?: boolean

Also generate Date

false

Since 2.5.0

withMap?: boolean

Also generate Map

false

Since 1.11.0

withNullPrototype?: boolean

Also generate object with null prototype

false

Since 1.23.0

withObjectString?: boolean

Also generate string representations of object instances

false

Since 1.17.0

withSet?: boolean

Also generate Set

false

Since 1.11.0

withSparseArray?: boolean

Also generate sparse arrays (arrays with holes)

false

Since 2.13.0

withTypedArray?: boolean

Also generate typed arrays in: (Uint|Int)(8|16|32)Array and Float(32|64)Array Remark: no typed arrays made of bigint

false

Since 2.9.0

withUnicodeString?: boolean

Replace the arbitrary of strings defaulted for key and values by one able to generate unicode strings with non-ascii characters. If you override key and/or values constraint, this flag will not apply to your override.

false

Since 3.19.0