Effect CommunityEC
Effect Community3y ago
6 replies
gavriguy

Handling Nullable Values in a Generator

Hi I have a question on failing when a value is nullable:

Inside a generator I would like to populate a const if another value is not nullable and fail if it is.

I managed to do so with the following code, but I think that there might be a more straitfowrward option:

const myValue = yield* _(
      Option.fromNullable(myPossibleNullableValue).pipe(
        Effect.catchAll(() => Effect.fail(new nullValueError()))
      )
    );
Was this page helpful?