feat(helpers): allow calling functions in fake placeholders#3841
feat(helpers): allow calling functions in fake placeholders#3841hiSandog wants to merge 2 commits intofaker-js:nextfrom
Conversation
✅ Deploy Preview for fakerjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## next #3841 +/- ##
==========================================
- Coverage 98.90% 98.87% -0.03%
==========================================
Files 899 900 +1
Lines 3113 3122 +9
Branches 574 578 +4
==========================================
+ Hits 3079 3087 +8
- Misses 30 31 +1
Partials 4 4
🚀 New features to boost your workflow:
|
|
Can you please restrict access to |
|
And don't forget to adjust the JSDocs +examples on faker.helpers.fake. |
|
Thanks for the review. I pushed a follow-up in a40cb4a that blocks |
There was a problem hiding this comment.
Please also remove/update this hint.
- It is also NOT possible to use any non-faker methods or plain javascript in such patterns.
| * faker.helpers.fake('You can visit me at {{location.streetAddress(true)}}.') // 'You can visit me at 3393 Ronny Way Apt. 742.' | ||
| * faker.helpers.fake('I flipped the coin and got: {{helpers.arrayElement(["heads", "tails"])}}') // 'I flipped the coin and got: tails' | ||
| * faker.helpers.fake('Your PIN number is: {{string.numeric(4, {"exclude": ["0"]})}}') // 'Your PIN number is: 4834' | ||
| * faker.helpers.fake('Generated code has length {{string.alphanumeric(10).length}}.') // 'Generated code has length 10.' |
There was a problem hiding this comment.
Please also add an example with a function call. e.g. date.toISOString()
| */ | ||
| function resolveProperty(entrypoint: unknown, key: string): unknown { | ||
| if (BLOCKED_PROPERTIES.has(key)) { | ||
| return undefined; |
There was a problem hiding this comment.
IMO this should throw. Because these should never be accessible.
|
@faker-js/maintainers Any suggestion for improving the PR title to better express the change? |
Think it is fine now |
Summary
Fixes #3465.
Validation