How to use the fp-ts/lib/Either.left function in fp-ts

To help you get started, we’ve selected a few fp-ts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paritytech / substrate-light-ui / packages / ui-common / src / util / validate.ts View on Github external
// FIXME: check for more methods as necessary
  if (!recipientAddress && extrinsic && extrinsic.method.methodName === 'transfer') {
    errors.recipientAddress = 'Please enter a recipient address.';
  }

  if (currentAccount === recipientAddress) {
    errors.currentAccount = 'You cannot send balance to yourself.';
  }

  if (!amountAsString) {
    errors.amount = 'Please enter an amount';
  }

  return Object.keys(errors).length
    ? left(errors)
    : right({ amountAsString, currentAccount, recipientAddress, extrinsic, ...rest } as Partial & UserInputs);
}
github teves-castro / ts-do / test / index.spec.ts View on Github external
    const failure: (l: string) => TaskEither = l => fromEither(left(l))
github rzeigler / waveguide / src / semaphore.ts View on Github external
(waiting) => [
                  makeTicket(latch.wait, cancelWait(n, latch)),
                                    left(waiting.offer([n, latch] as const)) as State
                ] as const,
                (ready) => ready >= n ?
github OliverJAsh / twitter-api-ts / src / helpers.ts View on Github external
export const createErrorResponse = (errorResponse: ErrorResponse): Response =>
    either.left(errorResponse);
github teamdigitale / io-functions / lib / controllers / messages.ts View on Github external
s.status
          ? {
              ...a,
              [s.channel.toLowerCase()]: s.status
            }
          : a,
      {}
    );
    return right>(some(response));
  } else {
    winston.error(
      `getMessageNotificationStatuses|Query error|${
        errorOrMaybeNotification.value.body
      }`
    );
    return left>(
      new Error(`Error querying for NotificationStatus`)
    );
  }
}
github rzeigler / waveguide / src / queue / nonblocking.ts View on Github external
              (waiting) => [new Ticket(IO.of(none), IO.void()), {...current, queue: left(waiting)}],
              (available) => {
github voteflux / THE-APP / packages / api / flux / handlers / login.ts View on Github external
const asyncChain = async (e: Either, f: (R) => Promise>): Promise> => {
    if (e.isRight())
        return await f(e.value)
    return left(e.value)
}
github teamdigitale / io-functions / lib / utils / mailup.ts View on Github external
)).chain(response => {
    if (response && response.Code && response.Code === "0") {
      return right(response);
    } else {
      return left(
        new Error(`Error sending email: ${response.Code}:${response.Message}`)
      );
    }
  });
}
github gcanti / hyper-ts / examples / routing.ts View on Github external
export const GET: Middleware = decodeMethod(s =>
  s.toLowerCase() === 'get' ? right('GET') : left('Unknown verb')
)
github paritytech / substrate-light-ui / packages / accounts-app / src / Staking / Setup.tsx View on Github external
    (errors: Errors) => left(errors),
    (accounts: Accounts) => right(accounts)