-
Notifications
You must be signed in to change notification settings - Fork 54
Description
Is your feature request related to a problem? Please describe.
When using the faker generators with dynamicValues: false
we get the attractive behavior of deterministically generated values that don't change when new types are added. This is great for tools like storybook and chromatic as a refresh doesn't change the values.
Unfortunately when we want to use custom types, we can't use the builtin faker directly. For instance if I have a Money
type defined I need to do something like toMoney(faker.number.int
). This pushes me into using dynamic values.
Describe the solution you'd like
With extra.function
I can use something like faker.number.int.toMoney()
but that would require extending the Number prototype. Instead I'd like to be able to do something like extra.wrapper
that could do toMoney(faker.number.int)
at codegen time.
Alternatively, if there's another way to get ahold of the seeded faker instance or type name or pretty much anything deterministic from a custom generator function that would be great too.
Describe alternatives you've considered
- Provide a wrapper function option for use with built-in faker types.
- Expose the seeded faker to custom generator functions
- Expose the type name or something similar to what the library uses to make deterministic values
- A way to specify that the generator should be run at generation time but not runtime?
Any additional important details?
I'm happy to attempt a PR if this is attractive and/or there is a preferred approach. Mostly looking for feedback/feasibility before going down that path.