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.

Remarks

Since 2.20.0

key?: Arbitrary<string>

Arbitrary for keys

Default Value

{@link string}

Remarks

Since 0.0.7

maxDepth?: number

Maximal depth allowed

Default Value

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

Remarks

Since 0.0.7

maxKeys?: number

Maximal number of keys

Default Value

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

Remarks

Since 1.13.0

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

Remarks

Since 2.22.0

values?: Arbitrary<unknown>[]

Arbitrary for values

Default Value

{@link boolean}, {@link integer}, {@link double}, {@link 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

Remarks

Since 0.0.7

withBigInt?: boolean

Also generate BigInt

Default Value

false

Remarks

Since 1.26.0

withBoxedValues?: boolean

Also generate boxed versions of values

Default Value

false

Remarks

Since 1.11.0

withDate?: boolean

Also generate Date

Default Value

false

Remarks

Since 2.5.0

withMap?: boolean

Also generate Map

Default Value

false

Remarks

Since 1.11.0

withNullPrototype?: boolean

Also generate object with null prototype

Default Value

false

Remarks

Since 1.23.0

withObjectString?: boolean

Also generate string representations of object instances

Default Value

false

Remarks

Since 1.17.0

withSet?: boolean

Also generate Set

Default Value

false

Remarks

Since 1.11.0

withSparseArray?: boolean

Also generate sparse arrays (arrays with holes)

Default Value

false

Remarks

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

Default Value

false

Remarks

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.

Default Value

false

Remarks

Since 3.19.0