Skip to content

Commit

Permalink
Merge pull request #24 from convox/app-name-validation
Browse files Browse the repository at this point in the history
validate app names. fixes convox/kernel#110
  • Loading branch information
ddollar committed Sep 16, 2015
2 parents cc7253c + a69a990 commit be65f63
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/models/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ func GetApp(name string) (*App, error) {
return app, nil
}

var regexValidAppName = regexp.MustCompile(`\A[a-z0-9_]{4,30}\z`)

func (a *App) Create() error {
helpers.SendMixpanelEvent("kernel-app-create-start", "")

if len(a.Name) < 2 {
helpers.SendMixpanelEvent("kernel-app-create-error", "")
return fmt.Errorf("invalid app name")
if !regexValidAppName.MatchString(a.Name) {
return fmt.Errorf("app name must be [a-z0-9_] and between 4 and 30 characters")
}

formation, err := a.Formation()
Expand Down

0 comments on commit be65f63

Please sign in to comment.