Giter Site home page Giter Site logo

fake-rs's People

Contributors

ajf-sa avatar andrewtoth avatar antono avatar birkenfeld avatar bryanmorgan avatar catflyflyfly avatar cksac avatar daamien avatar dejiah avatar frederikhaaning avatar jayvdb avatar joelmon avatar killercup avatar kornelski avatar kyle-mccarthy avatar kyrias avatar llogiq avatar mekagoza avatar mothsart avatar pickfire avatar robatipoor avatar roms1383 avatar saiintbrisson avatar simpsoneric avatar svenstaro avatar theanht1 avatar urkle avatar whiteccinn avatar xd009642 avatar yagince avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fake-rs's Issues

Ideas around address consistency, email validity, etc.

Also, you might notice a few more ideas about data one can generate at https://www.fakeaddressgenerator.com/ and https://www.fakepersongenerator.com/ i.e. stuff like IMEI.

You might consider an interface that makes generating "valid" address information possible. Afaik there are no existing fake address generators online that actually do this. It'd normally be undesirable, but who knows.

There are a couple free temporary email address providers like https://10minutemail.com/ In the past, I think they allowed offline generation of the valid email address, assuming you knew one of their currently active domains, but this appears gone now, and maybe with good reason.

Dynamic locale

All the examples I can find fix the locale to a specific one:

let val: String = Name(EN).fake();
let val: String = Name(ZH_TW).fake();

I'd like to generate data based on user-supplied argument, e.g

enum Locale {
    English,
    Taiwan,
    ...etc..
}

fn enthusiastic_fake_data(lo: Locale) -> String {
    format!("{}!!!", ...)
}

I couldn't find a neat way to do this - I can of course just do

let val: String = match {
    English => Name(EN).fake(),
    Taiwan => Name(ZH_TW).fake(),
}

..but this gets very repetitive if you also have a similar match for type of data (e.g Name, Country, etc)

I was hoping to do something like

let lo = match locale_arg {
    Locale::English => fake::locales::EN,
    Locale::Taiwan => fake::Local::ZH_TW,
};
let val: String = Name(lo).fake();

However this doesn't work as each local is it's own struct. I tried let lo: Box<dyn fake::locale::Data> = match ... and started running into more complex errors, so I started wondering if I was missing a simpler way to do this

Thanks!

**struct `Timestamp` is private** when using uuid 1.2

Failed to compile using uuid 1.2.

error[E0603]: struct `Timestamp` is private
  --> C:\Users\57438\.cargo\registry\src\github.com-1ecc6299db9ec823\fake-2.5.0\src\impls\uuid\mod.rs:24:28
   |
24 |         let ts = uuid::v1::Timestamp::from_rfc4122(ticks, counter);
   |                            ^^^^^^^^^ private struct
   |
note: the struct `Timestamp` is defined here
  --> C:\Users\57438\.cargo\registry\src\github.com-1ecc6299db9ec823\uuid-1.2.0\src\v1.rs:6:22
   |
6  | use crate::{Builder, Timestamp, Uuid};
   |                      ^^^^^^^^^

For more information about this error, try `rustc --explain E0603`.
error: could not compile `fake` due to previous error

'cargo test --features "dev" --verbose' fails on clippy_lints

This probably isn't preventing me from doing anything, but I'm reporting it in case I need to refer to it later or if there is/becomes a known fix.

forge@ubuntu:~/code/fantasy-faker$ rustc --version
rustc 1.11.0-nightly (696b703b5 2016-07-03)
forge@ubuntu:~/code/fantasy-faker$ cargo test --features "dev" --verbose
       Fresh nom v1.2.3
       Fresh unicode-normalization v0.1.2
       Fresh semver v0.2.3
       Fresh quine-mc_cluskey v0.2.2
       Fresh regex-syntax v0.3.3
       Fresh matches v0.1.2
       Fresh rustc-serialize v0.3.19
       Fresh toml v0.1.30
   Compiling clippy_lints v0.0.77
     Running `rustc /home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/lib.rs --crate-name clippy_lints --crate-type lib -g -C metadata=938fdfdda49ef511 -C extra-filename=-938fdfdda49ef511 --out-dir /home/forge/code/fantasy-faker/target/debug/deps --emit=dep-info,link -L dependency=/home/forge/code/fantasy-faker/target/debug/deps -L dependency=/home/forge/code/fantasy-faker/target/debug/deps --extern regex_syntax=/home/forge/code/fantasy-faker/target/debug/deps/libregex_syntax-6beef3475d06888b.rlib --extern toml=/home/forge/code/fantasy-faker/target/debug/deps/libtoml-6b7ee1318ccaaf57.rlib --extern unicode_normalization=/home/forge/code/fantasy-faker/target/debug/deps/libunicode_normalization-57bf4f7e307b7c87.rlib --extern matches=/home/forge/code/fantasy-faker/target/debug/deps/libmatches-6bf8698cf643c7bd.rlib --extern semver=/home/forge/code/fantasy-faker/target/debug/deps/libsemver-4efe754aa13a4d93.rlib --extern quine_mc_cluskey=/home/forge/code/fantasy-faker/target/debug/deps/libquine_mc_cluskey-f64f1f17fe9f33a4.rlib --extern rustc_serialize=/home/forge/code/fantasy-faker/target/debug/deps/librustc_serialize-7ce9989bca0848e8.rlib --cap-lints allow`
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/items_after_statements.rs:50:20: 50:35 error: failed to resolve. Use of undeclared type or module `DeclKind` [E0433]
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/items_after_statements.rs:50             if let DeclKind::Local(_) = decl.node {
                                                                                                                                                                 ^~~~~~~~~~~~~~~
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/items_after_statements.rs:50:20: 50:35 help: run `rustc --explain E0433` to see a detailed explanation
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/items_after_statements.rs:57:24: 57:38 error: failed to resolve. Use of undeclared type or module `DeclKind` [E0433]
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/items_after_statements.rs:57                 if let DeclKind::Item(ref it) = decl.node {
                                                                                                                                                                     ^~~~~~~~~~~~~~
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/items_after_statements.rs:57:24: 57:38 help: run `rustc --explain E0433` to see a detailed explanation
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/misc_early.rs:151:21: 151:36 error: failed to resolve. Use of undeclared type or module `DeclKind` [E0433]
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/misc_early.rs:151                 let DeclKind::Local(ref local) = first.node,
                                                                                                                                                       ^~~~~~~~~~~~~~~
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/utils/mod.rs:54:12: 54:46 note: in this expansion of if_let_chain! (defined in /home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/utils/mod.rs)
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/misc_early.rs:149:13: 163:15 note: in this expansion of if_let_chain! (defined in /home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/utils/mod.rs)
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/misc_early.rs:151:21: 151:36 help: run `rustc --explain E0433` to see a detailed explanation
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/returns.rs:96:17: 96:32 error: failed to resolve. Use of undeclared type or module `DeclKind` [E0433]
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/returns.rs:96             let DeclKind::Local(ref local) = decl.node,
                                                                                                                                               ^~~~~~~~~~~~~~~
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/utils/mod.rs:54:12: 54:46 note: in this expansion of if_let_chain! (defined in /home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/utils/mod.rs)
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/utils/mod.rs:54:12: 54:46 note: in this expansion of if_let_chain! (defined in /home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/utils/mod.rs)
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/returns.rs:92:9: 110:11 note: in this expansion of if_let_chain! (defined in /home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/utils/mod.rs)
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/returns.rs:96:17: 96:32 help: run `rustc --explain E0433` to see a detailed explanation
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/non_expressive_names.rs:71:22: 71:33 error: wrong number of lifetime parameters: expected 0, found 1 [E0107]
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/non_expressive_names.rs:71 impl<'v, 'a, 'b, 'c> Visitor<'v> for SimilarNamesNameVisitor<'a, 'b, 'c> {
                                                                                                                                                                 ^~~~~~~~~~~
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/non_expressive_names.rs:71:22: 71:33 help: run `rustc --explain E0107` to see a detailed explanation
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/non_expressive_names.rs:229:18: 229:29 error: wrong number of lifetime parameters: expected 0, found 1 [E0107]
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/non_expressive_names.rs:229 impl<'v, 'a, 'b> Visitor<'v> for SimilarNamesLocalVisitor<'a, 'b> {
                                                                                                                                                              ^~~~~~~~~~~
/home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/non_expressive_names.rs:229:18: 229:29 help: run `rustc --explain E0107` to see a detailed explanation
error: aborting due to 2 previous errors
error: Could not compile `clippy_lints`.

Caused by:
  Process didn't exit successfully: `rustc /home/forge/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.77/src/lib.rs --crate-name clippy_lints --crate-type lib -g -C metadata=938fdfdda49ef511 -C extra-filename=-938fdfdda49ef511 --out-dir /home/forge/code/fantasy-faker/target/debug/deps --emit=dep-info,link -L dependency=/home/forge/code/fantasy-faker/target/debug/deps -L dependency=/home/forge/code/fantasy-faker/target/debug/deps --extern regex_syntax=/home/forge/code/fantasy-faker/target/debug/deps/libregex_syntax-6beef3475d06888b.rlib --extern toml=/home/forge/code/fantasy-faker/target/debug/deps/libtoml-6b7ee1318ccaaf57.rlib --extern unicode_normalization=/home/forge/code/fantasy-faker/target/debug/deps/libunicode_normalization-57bf4f7e307b7c87.rlib --extern matches=/home/forge/code/fantasy-faker/target/debug/deps/libmatches-6bf8698cf643c7bd.rlib --extern semver=/home/forge/code/fantasy-faker/target/debug/deps/libsemver-4efe754aa13a4d93.rlib --extern quine_mc_cluskey=/home/forge/code/fantasy-faker/target/debug/deps/libquine_mc_cluskey-f64f1f17fe9f33a4.rlib --extern rustc_serialize=/home/forge/code/fantasy-faker/target/debug/deps/librustc_serialize-7ce9989bca0848e8.rlib --cap-lints allow` (exit code: 101)
forge@ubuntu:~/code/fantasy-faker$ cargo test 
   Compiling fake v0.3.0 (file:///home/forge/code/fantasy-faker)
     Running target/debug/fake-6985e80779624577

running 8 tests
test tests::address_usage ... ok
test tests::boolean_usage ... ok
test tests::company_usage ... ok
test tests::internet_usage ... ok
test tests::lorem_usage ... ok
test tests::name_usage ... ok
test tests::number_usage ... ok
test tests::phone_number_usage ... ok

test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured

   Doc-tests fake

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured

Return original Chrono values instead of `String`s

A project of mine stores DateTime<Utc> in some struct and would like to generate dummy timestamps for testing purposes. However this crate only returns Strings, and I had to convert them back to DateTime<Utc>, which would be a bit slow and even unreliable.

mode `fake` Is Missing Library Features After Enabling Them In Cargo.toml

Description

When attempting to run https://github.com/cksac/fake-rs/blob/master/fake/examples/derive.rs I ran into

the package `test_faker` depends on `fake`, with features: `rust_decimal` but `fake` does not have these features.

So I attempted to simplify things by changing my Cargo.toml declaration to include all features and use a simplier example code set and instead I ran into a similar run error but for a different feature set

the package `test_faker` depends on `fake`, with features: `random_color` but `fake` does not have these features.

I currently don't understand how I screwed this so I'm on here to ask about it.

Cargo.toml

[package]
name = "test_faker"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
fake = { version = "2.4", features=['derive', 'uuid', 'chrono', 'http', 'rust_decimal', 'random_color']}
rand = "0.8"

Code

cat src/main.rs
use fake::faker::boolean::en::*;
use fake::faker::company::en::*;
use fake::faker::name::en::*;
use fake::Dummy;
use fake::{Fake, Faker};

#[derive(Debug, Dummy)]
pub struct Order {
    #[dummy(faker = "1000..")]
    order_id: usize,

    #[dummy(faker = "Name()")]
    customer: String,

    #[dummy(faker = "(Faker, 3..5)")]
    items: Vec<Item>,

    #[dummy(faker = "Boolean(70)")]
    paid: bool,
}

#[derive(Debug, Dummy)]
pub struct Item {
    #[dummy(faker = "1..100")]
    product_id: usize,

    qty: u8,

    #[dummy(faker = "CompanyName()")]
    company: String,
}

fn main() {
    let order: Order = Faker.fake();
    println!("{:#?}", order);
}

Result

cargo run
error: failed to select a version for `fake`.
    ... required by package `test_faker v0.1.0 (/Users/alexlordthorsen/git/misc/investigations/eng_24270_performance_test_dms/test_faker)`
versions that meet the requirements `^2.4` are: 2.4.3

the package `test_faker` depends on `fake`, with features: `random_color` but `fake` does not have these features.


failed to select a version for `fake` which could resolve this conflict

A constructor fn attribute for 3rd party types?

I have a bunch of types which feature things like hyper::Body and Bytes, which don't have Dummy impls, I also can't impl them since they're third party types. I also can't restructure the structs, because I am using them with Serde to conform to a protocol.
Really I just want to initialize these to () and [], since I don't actually want them for my particular use case.

Is there a way to define a constructor function, similar to serde's serialize_with attribute?

Add docs to docs.rs

It may be useful to duplicate the examples from README to docs.rs/fake (fake lib.rs).

I tried looking at the docs in https://docs.rs/fake/2.4.0/fake/ but I don't seemed to see any examples there, but I found it in the README. Adding it to the top-level library docs allows the users to read the docs offline which could not be done with README.

proc macro panic

not sure if this is related to a rust version thing or if i did something wrong but i got this when trying to use Dummy derive

i'm using nightly 2019-07-14

error: proc-macro derive panicked
  --> crates/holochain_persistence_api/src/hash.rs:12:5
   |
12 |     Dummy, PartialOrd, PartialEq, Eq, Ord, Clone, Debug, Serialize, Deserialize, DefaultJson, Default, Hash,
   |     ^^^^^
   |
   = help: message: called `Result::unwrap()` on an `Err` value: Error { kind: UnsupportedShape("newtype"), locations: [], span: None }

Add date generators

I would like generators for all kinds of dates in different formats. For instance:

  • Date (Day, Month, Year, RFC/ISO notation, maybe even custom format)
  • Time (12h/24h notation)
  • DateTime (both of the above combined)
  • Duration generators

wasm-bindgen panics when use Faker

Was trying to implement web-assembly with rust:

#[wasm_bindgen]
fn get_random(){
    web_sys::console::log_1(&format!("Started").into());
    let fake_first_name = <Faker as Name>::first_name().to_string();
    web_sys::console::log_1(&format!("Found Name: {}", fake_first_name).into());
    let fake_last_name = <Faker as Name>::last_name().to_string();
    web_sys::console::log_1(&format!("Found Last Name: {}", fake_last_name).into());
}

But was getting this,

Error importing `index.js`: RuntimeError: unreachable
    at __rust_start_panic (wasm-function[171]:1)
    at rust_panic (wasm-function[101]:31)
    at std::panicking::rust_panic_with_hook::hb71d5fe4dc6cebd3 (wasm-function[41]:303)
    at std::panicking::begin_panic::hdec3e556b3fa2081 (wasm-function[98]:40)
    at rand::jitter::platform::get_nstime::h646b2b9d91a4f258 (wasm-function[135]:13)
    at rand::jitter::JitterRng::new::hd03a9b1ef4dffcb1 (wasm-function[152]:1)
    at rand::StdRng::new::haae3b4b181c13827 (wasm-function[27]:72)
    at rand::thread_rng::hd51e258c78071b8b (wasm-function[28]:36)
    at random_ten_million_peoples::get_random_person::h30f3f237eb89c289 (wasm-function[5]:166)
    at get_random_person (wasm-function[159]:5)

Then i checked the wasm-bindgen fearure of rust-random, seems to me that they have implemented wasm-bindgen features in their latest version,
https://github.com/rust-random/rand

and i have seen that you are still using version 0.3

[package]
name = "fake"
version = "1.2.2"
authors = ["cksac <[email protected]>"]
description = "An easy to use library for generating fake data like name, number, address, lorem, dates, etc."
keywords = ["faker", "data", "generator"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/cksac/fake-rs"
homepage = "https://github.com/cksac/fake-rs"

[dependencies]
rand = "0.3"
chrono = { version = "0.4", optional = true }
http = { version = "0.1", optional = true }

Issue with Faker on Enums

I'm receiving the following error when trying to use Dummy trait on a struct that contains an emum.

proc-macro derive panicked

help: message: called `Result::unwrap()` on an `Err` value: Error { kind: UnsupportedShape("enum"), locations: [], span: None }

From reviewing the crate, it seems like enums should be "fakeable", but minor tweaking doesn't help. If this is not the case, a use case on implementing the Dummy Trait would be great to have in the docs or examples.

Derive from json datatype?

Hello,

In order to generate a random amount of fake json properties i made this declaration.
#[derive(Debug, Dummy, Serialize)] struct SomeStruct { property : HashMap<String,String> //TODO:Extend to all datatypes }
However value is restricted to String, i wonder how to allow any datatype associated with json format to be randomly chosen as value.
Is there a way to implement Dummy for this datatype? https://docs.rs/serde_json/latest/serde_json/value/enum.Value.html

Regards,

I have a struct with a struct field, derive doesn't seem to work

The top level struct seems to have it's dummies used properly, but nested structs don't seem to use theirs no matter what I trye

Whats the proper syntax to get it use the dummy for a nested struct?

Especially when the nested struct is inside a vec

#[derive(Dummy)]
pub struct Derp{
  #[dummy(faker=???)]
  pub nested: Vec<Nested>
}

Nested has derive Dummy on it as well.

#dummy set on simple fields inside nested seem to work, but nothing on more complicated fields seems to work

Add recipe related fake data

I'm currently needing fake data for recipe and ingredients, including separated lists for vegetables, fruits, nuts etc.

I'd imagine something like this:

enum Category {
  Fruit,
  Vegetable,
  Nut,
  // etc...
}

Ingredient(category: Option<Category>);
Ingredients(count: usize, category: Option<Category>);
Recipe();
Recipes(count: usize);

As of now, I do not have recipe steps implemented but might add them later on. One thing that might actually be better would be moving the Ingredient call to a separate call like Fruit(), Vegetable(), Nut() and have Recipe re-use them. That way, they are not coupled to recipes and should make it clear that they can be used by their own.

If there is interest I can open a PR so you can merge my additions back into master.

fake object for person w/ consistent attributes

It would be great to be able to create a person object with first_name, last_name and email fields that were consistent with generated full name.

Workaround is to do something like this:

        let first = fake!(Name.first_name);
        let last = fake!(Name.last_name);
        let full_name = format!("{} {}", first, last);
        let first_initial = first.chars().next().unwrap();
        let email = format!("{}{}@{}", 
                    first_initial, 
                    last,
                    fake!(Internet.free_email_provider)).to_lowercase();


        println!("full name: {}", full_name); 
        println!("first: {}", first);
        println!("last: {}", last);
        println!("last: {}", email);

however, that loses some of the nice randomness in names with prefix, suffix, etc and would be nice if emails were randomized rather than always following a pattern

Readme example incomplete

Hi! Happy to see this library in Rust. :) But trying to follow the example it doesn't work as documented.

rustup show

rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/alex/.rustup

stable-x86_64-unknown-linux-gnu (default)
rustc 1.48.0 (7eac88abb 2020-11-16)

what I ran

Cargo.toml contains the derive feature, for Dummy.

use fake::{Dummy, Fake, Faker};

#[derive(Debug, Dummy)]
pub struct Foo {
    #[dummy(faker = "1000..2000")]
    order_id: usize,
    customer: String,
    paid: bool,
}

fn main() {
    // type derived Dummy
    let f: Foo = Faker.fake();
    println!("{:?}", f);
}

I expected it to print Foo.

errors

no rand

error[E0433]: failed to resolve: use of undeclared crate or module `rand`
 --> src/main.rs:3:17
  |
3 | #[derive(Debug, Dummy)]
  |                 ^^^^^ use of undeclared crate or module `rand`
  |
  = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

fixed once I add rand

Oke doke. I add use rand; and then in the Cargo.toml, I add rand = "0.7.3" (I see that in Cargo.lock as your version).

suggestion

Add Readme block describing the required dependency on rand or add it as a features entry?

version 2.4.2 not buildable with semver 1.x

It looks like the version of the semver crate was bumped from 0.11 to 1 with the last update (2.4.1 → 2.4.2). But when enabling the semver feature, it becomes apparent that the code was not updated for breaking changes between semver 0.11 and 1 at all:

error[E0603]: struct `Identifier` is private
   --> src/impls/semver/mod.rs:16:32
    |
16  |             pre = vec!(semver::Identifier::AlphaNumeric(format!(
    |                                ^^^^^^^^^^ private struct
    |
note: the struct `Identifier` is defined here
   --> /usr/share/cargo/registry/semver-1.0.4/src/lib.rs:103:5
    |
103 | use crate::identifier::Identifier;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0599]: no associated item named `AlphaNumeric` found for struct `semver::identifier::Identifier` in the current scope
  --> src/impls/semver/mod.rs:16:44
   |
16 |             pre = vec!(semver::Identifier::AlphaNumeric(format!(
   |                                            ^^^^^^^^^^^^ associated item not found in `semver::identifier::Identifier`

error[E0308]: mismatched types
  --> src/impls/semver/mod.rs:28:18
   |
28 |             pre: pre,
   |                  ^^^ expected struct `Prerelease`, found struct `Vec`
   |
   = note: expected struct `Prerelease`
              found struct `Vec<_>`

error[E0308]: mismatched types
  --> src/impls/semver/mod.rs:29:20
   |
29 |             build: vec!(),
   |                    ^^^^^^ expected struct `BuildMetadata`, found struct `Vec`
   |
   = note: expected struct `BuildMetadata`
              found struct `Vec<_>`
   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0308, E0599, E0603.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `fake` due to 4 previous errors

help on uuid v1 compat ...

Hello,

I'm struggling hard after the update of an other lib to using uuid v1^.
Since then this lib (async-graphql) and fake do not play together anymore.

Do you see a way I can force fake to use uuid v1 without forking it ?

gender on people

NameWithTitle(EN).fake() generate firstname and title without gender notion.

There is nothing also in FirstName(EN).fake(); to distinct by gender.

fake data generation seed

is there a way to provide the generator with a seed, so that, given the same seed, I will always get the same fake data back?

I'm trying to mock an external web server, and I would like to return fake data based on a provided id.

Many thanks for the great lib!

Basic example not working.

I'm trying to use the Dummy macro of fake v2.4.0, but I'm receiving this error message with basic examples.

error: cannot find derive macro `Dummy` in this scope
 --> src/main.rs:3:17
  |
3 | #[derive(Debug, Dummy)]
  |                 ^^^^^

error: cannot find attribute `dummy` in this scope
 --> src/main.rs:5:5
  |
5 |   #[dummy(faker = "1000..2000")]
  |     ^^^^^

warning: unused import: `Dummy`
 --> src/main.rs:1:12
  |
1 | use fake::{Dummy, Fake, Faker};
  |            ^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0277]: the trait bound `Foo: Dummy<Faker>` is not satisfied
  --> src/main.rs:12:22
   |
12 |   let f: Foo = Faker.fake();
   |                      ^^^^ the trait `Dummy<Faker>` is not implemented for `Foo`
   |
   = note: required because of the requirements on the impl of `fake::private::FakeBase<Foo>` for `Faker`

error: aborting due to 3 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0277`.
error: could not compile `pg-tests`

To learn more, run the command again with --verbose.

The code is:

use fake::{Dummy, Fake, Faker};

#[derive(Debug, Dummy)]
pub struct Foo {
  #[dummy(faker = "1000..2000")]
  order_id: usize,
  customer: String,
  paid: bool,
}

fn dummy_derive() {
  let f: Foo = Faker.fake();
  println!("{:?}", f);
}

fn main() {
  dummy_derive();
}

I'm new on rust and I'm not know why this are happening.

rustc --version: rustc 1.50.0 (cb75ad5db 2021-02-10)
cargo --version: cargo 1.50.0 (f04e7fab7 2021-02-04)

Add file generator

I would like to be able to generate some sensically named files with random extensions. I would also like a generator for only file extensions.

HTTP status code generators

I would like generators for HTTP status codes. I would like to have to ability to get just the strings, just the ints or both of them combined.

Extend fake-rs to cover more of Faker's functionality

Hi there! We are currently using faker (via pyo3) in synth and want to move to use fake-rs. However, to do that, we'd want fake-rs to match more of the functionality faker provides.

So we'd like to give this project a boost by trying to speed up that implementation work on that (I did the creditcardnumber stuff to check how hard that is). But before we go that route (and risk overwhelming you with PRs) I wanted to openly address you to learn your needs as a maintainer of this project and how we can best work together to our mutual benefit.

Minimum length word & Currencies

Well I am actually doing some magic to create some dummy data for blockchain project I am working on. The hack that I use is to get a word and then [0..3].to_uppercase to create a Crypto Currency, but then I thought It might be nice to be able to define how long you want the word to be.

But I also think that it might be nice to have Currencies as well into the crate? Supporting both some existing ones and custom one.

PS: My issue will be solved by using a list and choosing a random element, I was just looking for a quick hack to make everything working 😅

Upgrade to rand 0.8

Hi,

fake is incompatible with rand 0.8, it will be a long process to upgrade it?

Is it possible to generate fake data from a template?

I cannot find it in the docu/code and I have no clue how could I make it work myself in rust. I am referring to this feature from the faker.js lib https://fakerjs.dev/api/fake.html.

I need this feature because I want to define my object in a JSON (more likely RSON) and I need to define dynamically the fake template. Similar to the dummy derive but the templates are loaded from an external source at runtime.

How to use field decorations when deriving from structure

Hello,

Would it be possible to improve the documentation? I'm having a really hard time figuring out how to using derive Dummy and field decorations.

For example:

# [...]
pub struct Order {
    order_number: String,
    created_date:String,
    requested_ship_date: String,
    cancel_after_date: String,
    ship_to_name: String,
    ship_to_store: String,
    ship_to_address: String,
    ship_to_city: String,
    #[dummy("StateAbbr")]
    ship_to_state: String,
    ship_to_zip: String,
    all_po: Vec<Po>,
}

fn main() {
    let f: Order = Faker.fake();
    dbg!(f);
}

consistent address

I would like to generate an consistent address with timezone, longitude et latitude.
Nothing like this exists.

How do I expose implementation of Dummy when using cfg(test)?

I am using Dummy to create an object for testing so I've used [cfg_attr(test, derive(Dummy)] for the struct I want to fake. I have a "domain" crate where I have my models and then an "http_api" crate which depends on "domain". When I try to get a fake instance of my model struct, I get an error saying that Dummy is not implemented. Is there a way to "expose" that I've implemented the trait here that I'm missing or is this not possible when using cfg(test)? It works perfectly fine if I remove the #[cfg_attr(test, derive(Dummy)] from the struct and just derive it normally.

error[E0277]: the trait bound `domain::models::api_requests::PutRequest: Dummy<Faker>` is not satisfied
   --> http_api/src/local/filters.rs:154:48
    |
154 |         let request: PutRequest = Faker.fake();
    |                                                ^^^^ the trait `Dummy<Faker>` is not implemented for `domain::models::api_requests::PutRequest`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.