Skip to content

Correct custom provider example - #661

Merged
bodiam merged 2 commits into
datafaker-net:mainfrom
AlexJFerreira:patch-1
Jan 30, 2023
Merged

bodiam merged 2 commits into
datafaker-net:mainfrom
AlexJFerreira:patch-1

Conversation

@AlexJFerreira

@AlexJFerreira AlexJFerreira commented Jan 30, 2023 •

Copy link
Copy Markdown
Contributor

It's only possible to create a custom provider with BaseProviders instead of a Faker in it's constructor.

With Faker, it gets the following error: "reason: no instance(s) of type variable(s) exist so that BaseProviders conforms to Faker"

It's only possible to create a custom provider with BaseProviders instead of a Faker in it's constructor.
@what-the-diff

what-the-diff Bot commented Jan 30, 2023

Copy link
Copy Markdown
  • The constructor of the Insect class was changed to accept a BaseProviders object instead of Faker.
  • A new method called getName() was added which returns an insect name from INSECT_NAMES array randomly using faker's random().nextInt(INSECT_NAMES.length) function call and then returning that element in the array at index returned by nextInt().

@AlexJFerreira AlexJFerreira changed the title Correct cutom provider example Correct custom provider example Jan 30, 2023
@snuyanzin

Copy link
Copy Markdown
Collaborator

thanks
i would suggest to fix the same issue with InsectFromFile in same doc

Correct custom provider constructor example
@AlexJFerreira

Copy link
Copy Markdown
Contributor Author

thanks i would suggest to fix the same issue with InsectFromFile in same doc

Yeah, well noted. It's done.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #661 (189c88b) into main (d9d1ba3) will decrease coverage by 0.02%.
The diff coverage is n/a.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff              @@
##               main     #661      +/-   ##
============================================
- Coverage     92.70%   92.68%   -0.02%     
- Complexity     2631     2632       +1     
============================================
  Files           283      283              
  Lines          5426     5426              
  Branches        589      589              
============================================
- Hits           5030     5029       -1     
- Misses          243      245       +2     
+ Partials        153      152       -1     
Impacted Files Coverage Δ
...ain/java/net/datafaker/idnumbers/EnZAIdNumber.java 83.33% <0.00%> (-8.34%) ⬇️
.../java/net/datafaker/service/FakeValuesService.java 84.95% <0.00%> (+0.59%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@bodiam

bodiam commented Jan 30, 2023

Copy link
Copy Markdown
Contributor

Thanks! Merged!

@bodiam
bodiam merged commit 053e1e7 into datafaker-net:main Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants