Comments (10)
Shouldn’t that be lower
s
and no trailing space?
He's passing an argument to the next
method.
from datafaker.
EmployeeId','#{SequenceNumber.next ‘
Shouldn’t that be lower s
and no trailing space?
from datafaker.
🤷♂️ I could be totally wrong, I haven’t used this part of the lib yet.
from datafaker.
Hi @ako , I think you're using the wrong faker. In your example, you are using Faker
, but you should register the custom Provider at your own Faker. If you then do:
BugFaker faker = new BugFaker();
String data = faker.expression("#{csv ';','\"','true','10','EmployeeId','#{Insect.nextInsectName}','Firstname','#{Name.first_name}','Lastname','#{Name.last_name}'}");
System.out.println(data);
This seems to work. You can find the code I've used to reproduce it here:
https://github.com/datafaker-net/datafaker/tree/custom_csv_provider/src/test/java/net/datafaker/providers/base/bug
(sorry, it's a bit sloppy, but I hope it's clear enough)
This is mostly based on the documentation here:
https://www.datafaker.net/documentation/custom-providers/
If the above works for you, and you're willing to make the documentation more clear, that would be very appreciated!
from datafaker.
@ako
regarding
Goal is to enable my users to generate fake csv files with 100s of records for import into database tables using the expressions, so no need to do custom java coding for csv generation. The tables expect unique id values to identify the records.
have you looked at https://github.com/datafaker-net/datafaker-gen which could do what you've described without coding (only conf files)
from datafaker.
@bodiam Thanks, your suggestion to instantiate the sequence number Faker works, but i wonder how this is supposed to work if you have multiple custom providers?
from datafaker.
in case of multiple custom provider you can register all under custom faker
e.g.
public class BugFaker extends Faker {
public BugProvider insect() {
return getProvider(BugProvider.class, BugProvider::new, this);
}
}
there will be more than just one insect
method.
from datafaker.
how this is supposed to work if you have multiple custom providers?
The BugFaker is the entry point for all the custom generations. It should be called MyCompanyCustomFaker or so, where you can register a provider for Insects, Sequence Numbers, Tire sizes, etc, and in your code, instead of using Faker, you use your own subclass everywhere.
from datafaker.
#869
this should simplify current approach
from datafaker.
Hi @ako , I assume this issue is addressed, but feel free to reopen if it's not.
from datafaker.
Related Issues (20)
- Breaking DateAndTime HOT 4
- Intermitted expressions failures during testing HOT 8
- Regexify method doesn't recognise "^" and "$" chars in datafaker before 2.2.0. HOT 7
- Remove public methods from `IdNumber` that are not intended to be directly called HOT 8
- How to specify country-specific setting, not language-specific? HOT 2
- Feature request: add support to generate a random PNG/SVG. HOT 1
- 2.3.0 Release HOT 13
- Password generation does not always contain a lowercase letter HOT 3
- Publishing docs works now HOT 1
- Memory leak in maps containing FakerContext as a key HOT 30
- Memory leak for seeded random use case HOT 3
- Create a dictionary of obscene words HOT 8
- java.lang.ClassCastException for finance.credit_card provider with Enum argument in Faker expression HOT 5
- Problems with module-info.java with version 2.3.0 HOT 33
- New Project to improving tests HOT 9
- Locale specific generation performance degradation HOT 1
- Fix publishing of snapshots HOT 4
- Code coverage report is broken HOT 4
- Unable to resolve expression during build HOT 12
- Add weighted selection HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datafaker.