diff --git a/config.go b/config.go index a64bb0b..42607d0 100644 --- a/config.go +++ b/config.go @@ -53,6 +53,9 @@ type Config struct { // MinUpperCase represents the minimum amount of upper-case characters that have // to be part of the generated password MinUpperCase int64 + // MobileGrouping indicates if the generated password should be grouped in a + // mobile-friendly manner + MobileGrouping bool // Mode holds the different character modes for the Random algorithm Mode ModeMask // NumberPass sets the number of passwords that are generated @@ -175,6 +178,13 @@ func WithMaxLength(length int64) Option { } } +// WithMobileGrouping enables the mobile-friendly character grouping for AlgoRandom +func WithMobileGrouping() Option { + return func(config *Config) { + config.MobileGrouping = true + } +} + // WithModeMask overrides the default mode mask for the random algorithm func WithModeMask(mask ModeMask) Option { return func(config *Config) { diff --git a/config_test.go b/config_test.go index 1f43cd2..038d463 100644 --- a/config_test.go +++ b/config_test.go @@ -184,6 +184,18 @@ func TestWithMinUppercase(t *testing.T) { } } +func TestWithMobileGrouping(t *testing.T) { + c := NewConfig(WithMobileGrouping()) + if c == nil { + t.Errorf("NewConfig(WithMobileGrouping()) failed, expected config pointer but got nil") + return + } + if c.MobileGrouping != true { + t.Errorf("NewConfig(WithMobileGrouping()) failed, expected: %t, got: %t", + true, c.MobileGrouping) + } +} + func TestWithModeMask(t *testing.T) { e := DefaultMode c := NewConfig(WithModeMask(e))