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

Dummy to allow multiple fakers #170

Closed
NickLarsenNZ opened this issue Feb 29, 2024 · 2 comments
Closed

Dummy to allow multiple fakers #170

NickLarsenNZ opened this issue Feb 29, 2024 · 2 comments

Comments

@NickLarsenNZ
Copy link

I would like to generate some phone numbers and include both PhoneNumber() and CellNumber().

Is there a way to do that already?

To give an example of what I'm after:

Warning

This code does not work at the time of writing

#[derive(Debug, Dummy)]
struct Foo {
    #[dummy(faker = "PhoneNumber(), CellNumber()")]
    phone_number: String,
}
@cksac
Copy link
Owner

cksac commented Mar 1, 2024

added Either faker for String, https://github.com/cksac/fake-rs/blob/master/fake/examples/utils.rs

use fake::faker::phone_number::en::{CellNumber, PhoneNumber};
use fake::{utils::either, Dummy, Fake, Faker};

#[derive(Debug, Dummy)]
struct Foo {
    #[dummy(faker = "either(PhoneNumber(), CellNumber())")]
    phone_number: String,
}

@NickLarsenNZ
Copy link
Author

Thanks @cksac

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

No branches or pull requests

2 participants