Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

support user-supplied types #1

Closed
tmc opened this issue Jun 24, 2017 · 4 comments
Closed

support user-supplied types #1

tmc opened this issue Jun 24, 2017 · 4 comments

Comments

@tmc
Copy link

tmc commented Jun 24, 2017

No description provided.

@bxcodec
Copy link
Owner

bxcodec commented Jun 24, 2017

Can you provide some of explanation, please ? Some example, or something.

Currently, faker only support for some native types, and a non Pointer of Struct type.

For example :

type Another struct {
   Other string 
}
type Something struct {
   Another
   SomeField int 
}
 type Sample struct {
  SampleID int 
  SomethingObj Something
}

@nochso
Copy link

nochso commented Jul 1, 2017

How about an interface? Check for this interface when encountering structs and if it's implemented, call Fake.

type Faker interface {
    // Fake your own struct.
    Fake() error
}

Mail addresses or phone numbers are good examples because they should look a certain way.

type Mail string

func (m *Mail) Fake() error {
    m = "random@implementation.here"
    return nil
}

@bxcodec
Copy link
Owner

bxcodec commented Jul 6, 2017

@nochso
Cool.
I would appreciate for the pull request rather than a code snippet. Thanks

@bxcodec
Copy link
Owner

bxcodec commented Jul 10, 2017

Add new function here #5

Still need more example of data that already has a fixed pattern.
Maybe you could list more here LOL :D
So we can add the function

@bxcodec bxcodec closed this as completed Jul 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants