Created
September 24, 2018 20:19
-
-
Save cn007b/9be633bc93174edc0ebe1958f527fc90 to your computer and use it in GitHub Desktop.
eop - Implementation1 service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// service | |
func SignUp(username string) error { | |
if err := validation(username); err != nil { | |
return fmt.Errorf("validation failed, error: %s", err) | |
} | |
if err := signUpFacebook(username); err != nil { | |
return fmt.Errorf("facebook sign up failed, error: %s", err) | |
} | |
if err := signUpTwitter(username); err != nil { | |
return fmt.Errorf("twitter sign up failed, error: %s", err) | |
} | |
if err := signUpPinterest(username); err != nil { | |
return fmt.Errorf("pinterest sign up failed, error: %s", err) | |
} | |
return nil | |
} | |
func validation(username string) error { | |
if len(username) == 0 { | |
return fmt.Errorf("username cannot be blank") | |
} | |
return nil | |
} | |
func signUpFacebook(username string) error { | |
if username == "bond" { | |
return fmt.Errorf("username already taken") | |
} | |
return nil | |
} | |
func signUpTwitter(username string) error { | |
if username == "leiter" { | |
return fmt.Errorf("username already taken") | |
} | |
return nil | |
} | |
func signUpPinterest(username string) error { | |
if username == "q" { | |
return fmt.Errorf("username already taken") | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment