-
Notifications
You must be signed in to change notification settings - Fork 57
/
DomainMessage.kt
36 lines (24 loc) · 922 Bytes
/
DomainMessage.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.github.michaelbull.result.example.model.domain
/**
* All possible things that can happen in the use-cases
*/
sealed class DomainMessage
/* validation errors */
object CustomerRequired : DomainMessage()
object CustomerIdMustBePositive : DomainMessage()
object FirstNameRequired : DomainMessage()
object FirstNameTooLong : DomainMessage()
object LastNameRequired : DomainMessage()
object LastNameTooLong : DomainMessage()
object EmailRequired : DomainMessage()
object EmailTooLong : DomainMessage()
object EmailInvalid : DomainMessage()
/* events */
object CustomerCreated : DomainMessage()
class EmailAddressChanged(val old: String, val new: String) : DomainMessage()
/* exposed errors */
object CustomerNotFound : DomainMessage()
/* internal errors */
object SqlCustomerInvalid : DomainMessage()
object DatabaseTimeout : DomainMessage()
class DatabaseError(val reason: String?) : DomainMessage()