options

package
v4.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 7 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetGenerateUniqueValues

func SetGenerateUniqueValues(unique bool)

SetGenerateUniqueValues allows to set the single fake data generator functions to generate unique data.

func SetIgnoreInterface

func SetIgnoreInterface(ignore bool)

SetIgnoreInterface allows to set a flag to ignore found interface{}s.

func SetRandomMapAndSliceMaxSize

func SetRandomMapAndSliceMaxSize(size int) error

SetRandomMapAndSliceMaxSize sets the max size for maps and slices for random generation.

func SetRandomMapAndSliceMinSize

func SetRandomMapAndSliceMinSize(size int) error

SetRandomMapAndSliceMinSize sets the min size for maps and slices for random generation.

func SetRandomMapAndSliceSize

func SetRandomMapAndSliceSize(size int) error

SetRandomMapAndSliceSize sets the size for maps and slices for random generation. deprecates, currently left for old version usage

func SetRandomNumberBoundaries

func SetRandomNumberBoundaries(start, end int) error

SetRandomNumberBoundaries sets boundary for random number generation

func SetRandomStringLength

func SetRandomStringLength(size int) error

SetRandomStringLength sets a length for random string generation

func SetStringLang

func SetStringLang(l interfaces.LangRuneBoundary)

SetStringLang sets language of random string generation (LangENG, LangCHI, LangRUS, LangJPN, LangKOR, EmotEMJ)

Types

type MaxDepthOption

type MaxDepthOption struct {
	// contains filtered or unexported fields
}

MaxDepthOption used for configuring the max depth of nested struct for faker

func (*MaxDepthOption) ForgetType

func (o *MaxDepthOption) ForgetType(t reflect.Type)

func (*MaxDepthOption) RecursionOutOfLimit

func (o *MaxDepthOption) RecursionOutOfLimit(t reflect.Type) bool

func (*MaxDepthOption) RememberType

func (o *MaxDepthOption) RememberType(t reflect.Type)

type OptionFunc

type OptionFunc func(oo *Options)

OptionFunc define the options contract

func WithCustomFieldProvider

func WithCustomFieldProvider(fieldName string, provider interfaces.CustomProviderFunction) OptionFunc

WithCustomFieldProvider used for storing the custom provider function

func WithFieldsToIgnore

func WithFieldsToIgnore(fieldNames ...string) OptionFunc

WithFieldsToIgnore used for ignoring a field when generating the fake data

func WithGenerateUniqueValues

func WithGenerateUniqueValues(unique bool) OptionFunc

WithGenerateUniqueValues allows to set the single fake data generator functions to generate unique data.

func WithIgnoreInterface

func WithIgnoreInterface(value bool) OptionFunc

WithIgnoreInterface allows to set a flag to ignore found interface{}s.

func WithMaxGenerateStringRetries

func WithMaxGenerateStringRetries(retries uint) OptionFunc

WithMaxGenerateStringRetries set how much tries for generating random string

func WithNilIfLenIsZero

func WithNilIfLenIsZero(setNil bool) OptionFunc

WithNilIfLenIsZero allows to set nil for the slice and maps, if size is 0.

func WithRandomFloatBoundaries

func WithRandomFloatBoundaries(boundary interfaces.RandomFloatBoundary) OptionFunc

WithRandomFloatBoundaries sets the boundary for random float value generation. Boundaries should comply with float values constraints (IEEE 754)

func WithRandomIntegerBoundaries

func WithRandomIntegerBoundaries(boundary interfaces.RandomIntegerBoundary) OptionFunc

WithRandomIntegerBoundaries sets boundary random integer value generation. Boundaries can not exceed integer(4 byte...)

func WithRandomMapAndSliceMaxSize

func WithRandomMapAndSliceMaxSize(size uint) OptionFunc

WithRandomMapAndSliceMaxSize sets the max size for maps and slices for random generation.

func WithRandomMapAndSliceMinSize

func WithRandomMapAndSliceMinSize(size uint) OptionFunc

WithRandomMapAndSliceMinSize sets the min size for maps and slices for random generation.

func WithRandomStringLength

func WithRandomStringLength(size uint) OptionFunc

WithRandomStringLength sets a length for random string generation

func WithRecursionMaxDepth

func WithRecursionMaxDepth(depth uint) OptionFunc

WithRecursionMaxDepth used for configuring the max depth of recursion struct for faker

func WithSliceMapRandomToZero

func WithSliceMapRandomToZero(setNumberToZero bool) OptionFunc

WithSliceMapRandomToZero Sets random integer generation to zero for slice and maps

func WithStringLanguage

func WithStringLanguage(l interfaces.LangRuneBoundary) OptionFunc

WithStringLanguage sets language of random string generation (LangENG, LangCHI, LangRUS, LangJPN, LangKOR, EmotEMJ)

func WithTagName added in v4.2.0

func WithTagName(tagName string) OptionFunc

WithTagName sets the tag name to use. Default tag name is 'faker'.

type Options

type Options struct {
	// IgnoreFields used for ignoring a field when generating the fake data
	IgnoreFields map[string]struct{}
	// FieldProviders used for storing the custom provider function
	FieldProviders map[string]interfaces.CustomProviderFunction
	// MaxDepthOption used for configuring the max depth of nested struct for faker
	MaxDepthOption *MaxDepthOption
	// IgnoreInterface used for ignoring any interface field
	IgnoreInterface bool
	// StringLanguage used for setting the language for any string in faker
	StringLanguage *interfaces.LangRuneBoundary
	// GenerateUniqueValues to ensure the generated data is unique
	GenerateUniqueValues bool
	// RandomStringLength to ensure the generated string is expected as we want
	RandomStringLength int
	// RandomMaxSliceSize used for setting the maximum of slice size, or map size that will be generated
	RandomMaxSliceSize int
	// RandomMinSliceSize used for setting the minimum of slize, array, map size that will be generated
	RandomMinSliceSize int
	// MaxGenerateStringRetries set how much tries for generating random string
	MaxGenerateStringRetries int
	// SetSliceMapNilIfLenZero allows to set nil for the slice and maps, if size is 0.
	SetSliceMapNilIfLenZero bool
	// SetSliceMapRandomToZero sets random integer generation to zero for slice and maps
	SetSliceMapRandomToZero bool
	// RandomIntegerBoundary sets boundary random integer value generation. Boundaries can not exceed integer(4 byte...)
	RandomIntegerBoundary *interfaces.RandomIntegerBoundary
	// RandomFloatBoundary sets the boundary for random float value generation. Boundaries should comply with float values constraints (IEEE 754)
	RandomFloatBoundary *interfaces.RandomFloatBoundary
	// SetTagName sets the tag name that should be used
	TagName string
}

Options represent all available option for faker.

func BuildOptions

func BuildOptions(optFuncs []OptionFunc) *Options

BuildOptions build all option functions into one option

func DefaultOption

func DefaultOption() *Options

DefaultOption build the default option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL