George
02/04/2023, 12:22 PM// a union between unit and failure type, to avoid return type of nullable `Reject`
private sealed class ContinueOrReject
private object Continue : ContinueOrReject()
private class Reject(val rejectionDetails: RejectionDetails) : ContinueOrReject()
Any review or pov are welcomed and and thanks in advance for any answer !Joffrey
02/04/2023, 12:27 PMGeorge
02/04/2023, 12:34 PMContinue
to mark that the validation finished successfully.
my goal: avoid returning a Reject?
which means if is null then the validation finished successfully.George
02/04/2023, 12:36 PMIf the function is meant to retrieve or collect errors
an example of this would be to try
collect some data from somewhere which is known that are type of errors? Something like this?Joffrey
02/04/2023, 12:49 PMgetError(): SomeError?
wouldn't feel wrong to me. But saveFoo(foo: Foo): SomeError?
would seem strange, and I would prefer saveFoo(foo: Foo): Result
Joffrey
02/04/2023, 12:50 PMGeorge
02/04/2023, 1:05 PM