Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[scala] result code: fold
def processRequestCollections(userId: UUID, requestId: UUID): BusinessResult = {
getUser(userId).fold(BusinessResult.UserNotFound)(user => {
getRequestById(requestId).fold(BusinessResult.RequestNotFound)(request => {
checkAccess(request, user).toOption.fold(BusinessResult.NotOwner)(_ => BusinessResult.Ok)
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment