Skip to content

Commit

Permalink
Extract invalid uuid error
Browse files Browse the repository at this point in the history
  • Loading branch information
erickskrauch committed Dec 21, 2023
1 parent e84e39e commit add8ed1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,12 @@ func main() {
}
}

var InvalidUuid = errors.New("invalid uuid")

func formatUuid(input string) (string, error) {
uuid := strings.ReplaceAll(input, "-", "")
if len(uuid) != 32 {
return "", errors.New("invalid uuid")
return "", InvalidUuid
}

return uuid[0:8] + "-" + uuid[8:12] + "-" + uuid[12:16] + "-" + uuid[16:20] + "-" + uuid[20:], nil
Expand Down

0 comments on commit add8ed1

Please sign in to comment.