How to use the italia-ts-commons/lib/strings.EmailString.decode function in italia-ts-commons

To help you get started, we’ve selected a few italia-ts-commons 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 teamdigitale / io-functions / lib / utils / mailup.ts View on Github external
return addresses.map((address: NodemailerAddress) => {
    return {
      Email: EmailString.decode(address.address).getOrElseL(() => {
        // this never happens as nodemailer has already parsed
        // the email address (so it's a valid one)
        throw new Error(
          `Error while parsing email address (toMailupAddresses): invalid format '${
            address.address
          }'.`
        );
      }),
      Name: address.name || address.address
    };
  });
}
github teamdigitale / io-functions / lib / utils / middlewares / azure_user_attributes.ts View on Github external
return async request => {
    const errorOrUserEmail = EmailString.decode(
      request.header(HEADER_USER_EMAIL)
    );

    if (isLeft(errorOrUserEmail)) {
      return left, IAzureUserAttributes>(
        ResponseErrorInternal(
          `Missing, empty or invalid ${HEADER_USER_EMAIL} header`
        )
      );
    }

    const userEmail = errorOrUserEmail.value;

    const errorOrUserSubscriptionId = NonEmptyString.decode(
      request.header(HEADER_USER_SUBSCRIPTION_KEY)
    );