Skip to content

Commit

Permalink
fix: added validation on initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
Karim-W committed Jul 25, 2023
1 parent 84296f7 commit 90ed116
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cafe.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func (s *Cafe) Initialize() error {
}
switch v.typ {
case "string":
if v.isRequired && val == "" {
return Err_REQUIRED_KEY_MISSING
}
v.Value = val
case "int":
v.Value, err = strconv.Atoi(val)
Expand All @@ -102,6 +105,7 @@ func (s *Cafe) Initialize() error {
}
return nil
}

func (s *Cafe) GetString(k string) (string, error) {
spilt := strings.Split(k, ".")
if len(spilt) == 1 {
Expand Down

0 comments on commit 90ed116

Please sign in to comment.