Closed linxkaa closed 9 months ago
Hi @linxkaa
Without knowing about the implementation of FormValidator
I can say that somehow one of _emptyLeftErrorMsg
, _emptyRightErrorMsg
, or _zeroRightErrorMsg
returns None
.
In the case of Either
since _emptyLeftErrorMsg
returns Left
then _emptyRightErrorMsg
and _zeroRightErrorMsg
are "skipped". This is not the case with some
in Option
Hi @SandroMaglione thank you for answering.
But as you can see in the code, when Im using either it returns the correct statement which is left. And should've work the same with option, if the _emptyLeftErrorMsg is returning failure -> Should've returning some()
I event print inside the _emptyLeftErrorMsg, and its returning some('Left form must not be empty')
So Im kind of confused why .andThen
doesn't work in Option
andThen
executes the function only when the current value is not Left
(Either
) or None
(Option
).
Your example works with Either
because you wrap the result in left
. andThen
will therefore not execute at all and skip to fold
.
With Option
you return some
, which instead continues the execution of andThen
possibly causing a failure later in the code
I see, alright then. Closing this question. Thankyou!
Hi, I have this code:
This code works perfectly for instance the
_emptyLeftErrorMsg
returnleft('Left form must not be empty')
then thetextErrorMsg
will return theerrorText
But when I change to this code:
it always return null even though the
_emptyLeftErrorMsg
returnsome('Left form must not be empty')
Is there no way to use
.andThen
in Option?