Last active
October 27, 2018 13:06
-
-
Save cn007b/831925197950c501ec78093f23e15259 to your computer and use it in GitHub Desktop.
GO ValueObject - vo part 3
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
// initName performs naive name validation (just for sake of example) | |
// and provides 100% guarantee that vo contains valid name. | |
func (i *Instance) initName(data map[string]string) { | |
name, exists := data["name"] | |
if !exists || name == "" { | |
i.errors["name"] = "invalid name" | |
return | |
} | |
i.name = name | |
} | |
// initEmail same like initName. | |
func (i *Instance) initEmail(data map[string]string) { | |
email, exists := data["email"] | |
if !exists || email == "" { | |
i.errors["email"] = "invalid email" | |
return | |
} | |
i.email = email | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment