Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

slice_len only works for string #153

Closed
trynity opened this issue Jan 7, 2022 · 0 comments · Fixed by #169
Closed

slice_len only works for string #153

trynity opened this issue Jan 7, 2022 · 0 comments · Fixed by #169

Comments

@trynity
Copy link

trynity commented Jan 7, 2022

Right now, slice_len does not actually work for a slice of integers/bytes, despite what the example has: https://github.com/bxcodec/faker/blob/master/example_with_tags_slicelength_test.go

If you add a slice of integers to the test: https://github.com/bxcodec/faker/blob/master/faker_test.go#L650

It will fail with "Invalid Tags" here: https://github.com/bxcodec/faker/blob/master/faker.go#L921

The reason you don't see similar with Strings is because the similar check in extractStringFromTag, we always have lang set: https://github.com/bxcodec/faker/blob/master/faker.go#L858

I wasn't sure how best to approach this, whether we should just have a check accepting slice_len as an additional tag in extractNumberFromTag or some other cleaner way, but dem's de facts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants