Skip to content

Throwing an Error when passing empty array to helpers.ArrayElements #920

Description

@c0per

Describe the bug

When passing in an empty Array to helpers.ArrayElements, I'm hoping it to return an empty Array.
Instead it throws this Error:

Uncaught Error: Max 0 should be larger then min 1.
    at i0.number (https://cdn.esm.sh/v78/@faker-js/faker@6.3.1/deno/faker.js:2:2634645)
    at s0.arrayElements (https://cdn.esm.sh/v78/@faker-js/faker@6.3.1/deno/faker.js:4:7275)
    at <anonymous>:2:15

Reproduction

Simply faker.helpers.arrayElements([]);

Additional Info

I'm using version v6.3.1 on Deno.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: bugSomething isn't workinghas workaroundWorkaround provided or linkedp: 1-normalNothing urgents: acceptedAccepted feature / Confirmed bug

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions