Skip to content
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

✨ Faker.js pass function arguments #64

Open
fuzulus opened this issue Mar 21, 2021 · 3 comments
Open

✨ Faker.js pass function arguments #64

fuzulus opened this issue Mar 21, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@fuzulus
Copy link

fuzulus commented Mar 21, 2021

The concrete problem for me appeared on the phoneNumber Faker.js function where it is possible to pass the phoneFormat as an argument but it is not possible via the JSON file in which I write my mocked API configuration.

It would be nice to be able to pass function arguments. I looked into the current parser implementation, it seems plausible to update it with a feature such as this one.

I believe it would require an additional split/check on the fakerMethod once the first split(':') is done. :)

E.g.
[#faker:phone:phoneNumber('+385#######')]

@johannchopin
Copy link
Owner

Hey @fuzulus 👋 Thanks for opening an issue.

Yes it shouldn't be a huge problem to add this feature. Like you already find out we can just extend the logic of the areFakerVarsSyntaxValidInContent function to extract the parameters and give them back in the FakerSyntaxData object.

But I guess we will need then to use a try catch block to be sure that the syntax with the parameters is valid 🤔

I saw you already created a fork of Restapify do you want to take care of the implementation?

@johannchopin johannchopin added the enhancement New feature or request label Mar 22, 2021
@fuzulus
Copy link
Author

fuzulus commented Mar 24, 2021

Hey @johannchopin, yeah if it's not too urgent for you to get this one out I can take care of the implementation over the weekend and make a PR for review. 😄

@johannchopin
Copy link
Owner

Hey @fuzulus 👋 Do you need some extra help for this one? 😉 If you like to work in TDD I could provide you the tests for it 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants