Skip to content

Commit

Permalink
🧼 Remove the validate method from catalog struct as that logic has be…
Browse files Browse the repository at this point in the history
…en pushed into the catalog constructor
  • Loading branch information
carloscasalar committed Dec 8, 2024
1 parent 3402a2b commit 6c76e24
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions pkg/generator/default_name_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ func NewDefaultNameGenerator() (NameGenerator, error) {
if err := yaml.Unmarshal(assets.EmbedNames, &config); err != nil {
return nil, fmt.Errorf("error unmarshalling names config file: %v", err)
}
if err := config.Validate(); err != nil {
return nil, fmt.Errorf("error parsing names config file: %v", err)
}

return NewCatalogSourcedNameGenerator(config.Surnames, config.NonGenderedNames, config.FemaNames, config.MaleNames)
}
Expand All @@ -24,20 +21,3 @@ type nameConfig struct {
FemaNames []string `yaml:"female_names,flow"`
MaleNames []string `yaml:"male_names,flow"`
}

func (c nameConfig) Validate() error {
if len(c.Surnames) == 0 {
return fmt.Errorf("surnames cannot be empty")
}
if len(c.NonGenderedNames) == 0 {
return fmt.Errorf("non_gendered_names cannot be empty")
}
if len(c.FemaNames) == 0 {
return fmt.Errorf("female_names cannot be empty")
}
if len(c.MaleNames) == 0 {
return fmt.Errorf("male_names cannot be empty")
}

return nil
}

0 comments on commit 6c76e24

Please sign in to comment.