Getting RangeError when using faker.string.alphanumeric without specifying max #2372
-
I am using faker.string.alphanumeric with only min length specified in options. It gives a rangeError. Works fine if both min and max are specified.
Is this expected behaviour i.e length option should have both min and max specified always? If not, I am assuming this could be because the Number.MAX_SAFE_INTEGER used in rangeToNumber here is greater than max Array length. Complete error trace here RangeError: Invalid array length
at Function.from (<anonymous>)
at A.multiple (<workspace>/node_modules/@faker-js/faker/dist/cjs/modules/helpers/index.js:3:723)
at x.fromCharacters (<workspace>/node_modules/@faker-js/faker/dist/cjs/modules/string/index.js:1:1049)
at x.alphanumeric (<workspace>/node_modules/@faker-js/faker/dist/cjs/modules/string/index.js:1:1901)
at Object.<anonymous> (<workspace>/test-faker.js:3:26)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
According to our API docs: |
Beta Was this translation helpful? Give feedback.
According to our API docs:
number | { min: number, max: number }
the length.max parameter is required.https://fakerjs.dev/api/string.html#alphanumeric