Created
August 8, 2014 11:04
-
-
Save no-longer-on-githu-b/d77e22ad5c47c4a17eab to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def saveUser(ds: DataSource)(user: User): UserID = { | |
// blabla | |
} | |
abstract class UserValidationError | |
case object FirstNameEmpty extends UserValidationError | |
case object LastNameEmpty extends UserValidationError | |
def createUser(saveUser: User => UserID)(firstName: String, lastName: String): ValidationNel[UserValidationError, UserID] = { | |
def validateFirstName(name: String) = if (name.isEmpty) FirstNameEmpty.fail else name.success | |
(validateFirstName ⊛ validateLastName)(User(_, _)) map saveUser | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment