-
-
Notifications
You must be signed in to change notification settings - Fork 919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove default value from helpers.arrayElement()
#581
Comments
If calling the method with an empty array is considered a bug, what would be the correct behavior for empty arrays? |
IMO we should "just" remove the |
If it could return |
Can you assign me either way? |
random.arrayElement()
helpers.arrayElement()
Fixed by #2045. |
faker/src/random.ts
Lines 106 to 108 in 4eef328
This causes issues with missing data, that then gets magically replaced with these defaults, which results in unexpected behavior.
This change could be considered breaking, but IMO calling that method without an array to choose from is a bug itself.
Thus why I consider this a bug, that needs fixing more than retaining backwards compatibility.
We observed this method misbehaving in our tests before.
Alternatives considered
Create a new method and deprecate the old one.
Additional Information
Related to #219
The text was updated successfully, but these errors were encountered: